/* Survey index */
.surveys-index-page .section--soft { position: relative; background: var(--canvas); }
.surveys-index-page .section--soft::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 5px;
  background: var(--blue);
}

.survey-toolbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 24px;
  align-items: center;
  margin-bottom: 54px;
  padding: 22px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
}

.survey-toolbar--spaced { margin-top: 12px; }
.search-field { position: relative; min-width: 0; }
.search-field svg { position: absolute; top: 50%; left: 16px; width: 20px; height: 20px; color: var(--ink); transform: translateY(-50%); pointer-events: none; }
.search-field input { width: 100%; min-height: 54px; padding: 11px 15px 11px 48px; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-sm); outline: 0; font-weight: 700; }
.search-field input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36, 79, 158, 0.16); }

.segmented-control { display: inline-flex; gap: 0; background: var(--paper-muted); border: 1px solid var(--ink); }
.segmented-control button { min-height: 44px; padding: 8px 16px; color: var(--ink); background: transparent; border: 0; border-right: 2px solid var(--ink); font-size: 0.76rem; font-weight: 900; cursor: pointer; }
.segmented-control button:last-child { border-right: 0; }
.segmented-control button:hover { background: var(--blue-soft); }
.segmented-control button[aria-pressed="true"] { color: var(--ink); background: var(--yellow-soft); }

.surveys-index-page .survey-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
.surveys-index-page .survey-card { min-height: 380px; }
.surveys-index-page .survey-card:nth-child(4n + 2),
.surveys-index-page .survey-card:nth-child(4n + 3) { color: var(--ink); background: var(--paper); }
.surveys-index-page .survey-card:nth-child(4n + 3) > p,
.surveys-index-page .survey-card:nth-child(4n + 3) .survey-card__dates,
.surveys-index-page .survey-card:nth-child(4n + 3) .survey-card__footer { color: var(--muted); }
.surveys-index-page .survey-card:nth-child(4n + 3) .text-link { color: var(--blue); }
.survey-card--closed { opacity: 0.72; }
.survey-card--closed::before { background: var(--ink); }

/* Survey response workspace */
.survey-topbar {
  position: sticky;
  z-index: 40;
  top: 0;
  min-height: 72px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 0 max(22px, calc((100vw - 1320px) / 2));
  color: var(--paper);
  background: var(--ink);
  border-bottom: 3px solid var(--blue);
}

.survey-topbar .brand { color: var(--paper); }
.survey-topbar .brand__mark { width: 44px; height: 44px; flex-basis: 44px; }
.survey-topbar .brand__text strong { font-size: 0.86rem; }
.survey-topbar__actions { display: flex; align-items: center; gap: 8px; }
.survey-topbar .icon-button { color: var(--paper); background: transparent; border-color: var(--paper); box-shadow: none; }
.survey-topbar .icon-button:hover { color: var(--ink); background: var(--paper); }

.survey-layout {
  position: relative;
  min-height: calc(100vh - 72px);
  padding: 70px 0 110px;
  background-color: var(--canvas);
}

.survey-layout::before { display: none; }

.survey-layout__inner { position: relative; z-index: 1; width: min(calc(100% - 48px), 900px); margin-inline: auto; }

.survey-header-card,
.consent-card,
.question-card,
.password-card,
.success-panel {
  min-width: 0;
  padding: 34px 40px;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--radius-md);
}

.survey-header-card { position: relative; overflow: hidden; margin-bottom: 30px; padding: 50px 48px 40px; border-top: 5px solid var(--blue); }
.survey-header-card::before { content: "HCCCR / SURVEY"; position: absolute; top: 0; right: 0; padding: 7px 10px; color: var(--blue); background: var(--blue-soft); border-bottom: 1px solid var(--blue); border-left: 1px solid var(--blue); font-size: 0.64rem; font-weight: 900; }
.survey-header-card::after { display: none; }
.survey-header-card .meta-row { max-width: 100%; padding-right: 0; }
.survey-header-card h1 { position: relative; z-index: 1; max-width: 720px; margin: 26px 0 14px; font-size: 3.25rem; font-weight: 900; line-height: 1.08; overflow-wrap: anywhere; word-break: break-word; }
.survey-header-card > p { position: relative; z-index: 1; max-width: 720px; margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.75; }
.survey-meta { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 10px 22px; margin-top: 30px; padding-top: 18px; border-top: 1px solid var(--line); }
.survey-meta span { display: inline-flex; align-items: center; gap: 7px; color: var(--ink-soft); font-size: 0.76rem; font-weight: 700; }
.survey-meta svg { width: 16px; height: 16px; }

.password-card,
.consent-card { margin-bottom: 28px; }
.survey-demo-notice { margin-bottom: 18px; }
.password-card { border-left: 5px solid var(--blue); }
.consent-card { background: var(--paper); border-left: 5px solid var(--blue); }
.gate-heading { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 18px; align-items: start; }
.gate-heading__icon { width: 50px; height: 50px; display: grid; place-items: center; color: var(--blue-ink); background: var(--blue-soft); border: 2px solid var(--blue-ink); border-radius: 50%; }
.password-card .gate-heading__icon { color: var(--paper); background: var(--red); border-color: var(--ink); }
.gate-heading__icon svg { width: 22px; height: 22px; }
.gate-heading h2,
.gate-heading p { margin: 0; }
.gate-heading h2 { font-size: 1.28rem; line-height: 1.35; }
.gate-heading p { margin-top: 5px; color: var(--muted); font-size: 0.84rem; }
.gate-body { margin-top: 24px; }
.gate-body label:not(.check-row) { display: block; margin-bottom: 8px; color: var(--ink); font-size: 0.8rem; font-weight: 900; }
.gate-body input[type="password"] { width: 100%; min-height: 52px; padding: 11px 13px; background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-sm); outline: 0; }
.gate-body input[type="password"]:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36, 79, 158, 0.16); }
.gate-actions { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
.consent-summary { max-height: 230px; overflow: auto; padding: 20px; color: var(--ink-soft); background: var(--paper); border: 2px solid var(--ink); font-size: 0.84rem; }
.consent-summary p { margin: 0 0 11px; }
.consent-summary p:last-child { margin-bottom: 0; }
.consent-summary ul { margin: 0 0 11px; padding-left: 22px; }
.consent-summary a { color: var(--blue); font-weight: 900; }
.consent-card .check-row { margin-top: 20px; }

.questions-shell { position: relative; min-width: 0; max-width: 100%; }
.questions-list { min-width: 0; max-width: 100%; display: grid; gap: 18px; counter-reset: question; }
.survey-section-heading { position: relative; min-width: 0; margin: 42px 0 6px; padding: 30px 34px 28px; color: var(--ink); background: var(--paper-muted); border: 1px solid var(--line-strong); border-left: 5px solid var(--blue); scroll-margin-top: 92px; }
.survey-section-heading:first-child { margin-top: 0; }
.survey-section-heading::after { display: none; }
.survey-section-heading > span { display: block; margin-bottom: 7px; color: var(--blue-ink); font-family: var(--font-display); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; }
.survey-section-heading h2 { max-width: 100%; margin: 0; color: var(--ink); font-size: 1.9rem; font-weight: 900; line-height: 1.25; overflow-wrap: anywhere; word-break: break-word; }
.survey-section-heading p { max-width: 680px; margin: 9px 0 0; color: var(--ink-soft); overflow-wrap: anywhere; }

.questions-shell.is-locked .questions-list { opacity: 0.25; filter: grayscale(1); user-select: none; }
.locked-overlay { position: absolute; z-index: 4; inset: 0; min-height: 300px; display: grid; place-items: start center; padding-top: 88px; }
.locked-overlay__content { min-height: 54px; display: inline-flex; align-items: center; gap: 9px; padding: 13px 18px; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-left: 5px solid var(--blue); box-shadow: var(--shadow-sm); font-size: 0.82rem; font-weight: 900; }
.locked-overlay__content svg { width: 18px; height: 18px; }

.question-card { position: relative; max-width: 100%; margin: 0; border-left: 4px solid var(--line-strong); scroll-margin-top: 94px; transition: border-color var(--motion), box-shadow var(--motion); }
.question-card:nth-of-type(odd) { border-left-color: var(--line-strong); }
.question-card:focus-within { border-left-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
fieldset.question-card { min-inline-size: 0; }
.question-card legend,
.question-label { width: 100%; max-width: 100%; display: block; padding: 0; color: var(--ink); font-size: 1.08rem; font-weight: 900; line-height: 1.58; overflow-wrap: anywhere; word-break: break-word; white-space: normal; }
fieldset.question-card > legend { float: left; }
fieldset.question-card > legend + * { clear: both; }
.required-mark { margin-left: 4px; color: var(--red); font-size: 1.1em; font-weight: 900; }
.question-description { max-width: 100%; margin: 9px 0 0; color: var(--muted); font-size: 0.84rem; overflow-wrap: anywhere; }

.options-list { display: grid; gap: 10px; margin-top: 20px; }
.option-row { min-width: 0; min-height: 54px; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 13px; align-items: center; padding: 11px 14px; background: var(--paper); border: 2px solid var(--ink); cursor: pointer; transition: background var(--motion), transform var(--motion), box-shadow var(--motion); }
.option-row:hover { background: var(--blue-soft); }
.option-row:has(input:checked) { background: var(--blue-soft); box-shadow: inset 4px 0 0 var(--blue); }
.option-row input { appearance: none; width: 20px; height: 20px; margin: 0; background: var(--paper); border: 2px solid var(--ink); }
.option-row input[type="radio"] { border-radius: 50%; }
.option-row input:checked { background: var(--blue); box-shadow: inset 0 0 0 4px var(--paper); }
.option-row span { min-width: 0; overflow-wrap: anywhere; }

.text-input,
.date-input,
.textarea-input { width: 100%; min-width: 0; min-height: 52px; margin-top: 19px; padding: 11px 13px; color: var(--ink); background: var(--paper); border: 2px solid var(--ink); border-radius: var(--radius-sm); outline: 0; }
.textarea-input { min-height: 145px; resize: vertical; }
.text-input:focus,
.date-input:focus,
.textarea-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(36, 79, 158, 0.16); }
.question-card.has-error { border-color: var(--red); border-left-color: var(--red); box-shadow: 0 0 0 2px var(--danger-soft); }

.progress-line { position: sticky; z-index: 8; bottom: 0; height: 10px; overflow: hidden; margin-top: 30px; background: var(--paper-muted); border: 2px solid var(--ink); }
.progress-line span { display: block; width: 0; height: 100%; background: var(--blue); transition: width 180ms linear; }
.form-footer { display: flex; justify-content: space-between; align-items: center; gap: 22px; margin-top: 0; padding: 24px 28px; background: var(--paper); border: 2px solid var(--ink); border-top: 0; }
.form-footer p { margin: 0; color: var(--muted); font-size: 0.76rem; }
.survey-footnote { margin: 34px 0 0; color: var(--muted); font-size: 0.72rem; text-align: center; }
.survey-footnote a { color: var(--blue); font-weight: 900; }

.success-panel { padding: 72px 54px; border-left: 5px solid var(--blue); text-align: center; }
.success-panel__icon { width: 66px; height: 66px; display: grid; place-items: center; margin: 0 auto 24px; color: #33472c; background: var(--success-soft); border: 2px solid var(--success); border-radius: 50%; }
.success-panel__icon--danger { color: var(--paper); background: var(--red); border-color: var(--ink); }
.success-panel__icon--blue { color: var(--blue-ink); background: var(--blue-soft); border-color: var(--blue); }
.success-panel__icon svg { width: 30px; height: 30px; }
.success-panel h2 { margin: 0; font-size: 3rem; }
.success-panel p { max-width: 580px; margin: 14px auto 0; color: var(--muted); }
.success-panel > div:last-child { margin-top: 28px; }
.reference-code { display: block; width: fit-content; max-width: 100%; margin: 24px auto 0; padding: 11px 15px; color: var(--blue-ink); background: var(--blue-soft); border: 1px dashed var(--blue); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; overflow-wrap: anywhere; }
.branch-terminal-card { border-left: 5px solid var(--blue); }

@media (max-width: 900px) {
  .surveys-index-page .survey-grid { grid-template-columns: 1fr; }
  .surveys-index-page .survey-card:nth-child(n) { min-height: 320px; transform: none; }
  .survey-layout::before { display: none; }
}

@media (max-width: 720px) {
  .survey-toolbar { grid-template-columns: 1fr; gap: 14px; margin-bottom: 38px; padding: 16px; box-shadow: none; }
  .survey-toolbar .segmented-control { width: 100%; }
  .survey-toolbar .segmented-control button { min-width: 0; flex: 1 1 0; padding-inline: 7px; }
  .survey-topbar { min-height: 64px; padding-inline: 14px; }
  .survey-topbar .brand__text { display: block; }
  .survey-topbar .brand__text strong { max-width: 180px; }
  .survey-layout { min-height: calc(100vh - 64px); padding: 34px 0 76px; }
  .survey-layout__inner { width: min(calc(100% - 24px), 900px); }
  .survey-header-card,
  .consent-card,
  .question-card,
  .password-card,
  .success-panel { padding: 24px 20px; box-shadow: none; }
  .survey-header-card { padding-top: 42px; border-left-width: 2px; }
  .survey-header-card::after { top: 33px; right: 16px; width: 42px; height: 42px; }
  .survey-header-card .meta-row { max-width: 100%; }
  .survey-header-card h1 { margin-top: 20px; font-size: 2.2rem; }
  .survey-meta { display: grid; gap: 9px; }
  .password-card,
  .consent-card { border-left-width: 5px; }
  .gate-heading { grid-template-columns: 42px minmax(0, 1fr); gap: 13px; }
  .gate-heading__icon { width: 41px; height: 41px; }
  .gate-heading h2 { font-size: 1.05rem; }
  .consent-summary { max-height: 200px; padding: 15px; }
  .survey-section-heading { margin-top: 30px; padding: 24px 19px 20px; border-left-width: 2px; }
  .survey-section-heading::after { display: none; }
  .survey-section-heading h2 { max-width: 100%; font-size: 1.55rem; }
  .question-card { border-left-width: 4px; }
  .question-card legend,
  .question-label { font-size: 1rem; line-height: 1.58; }
  .option-row { min-height: 52px; padding: 10px 11px; }
  .form-footer { align-items: stretch; flex-direction: column; padding: 20px; box-shadow: none; }
  .form-footer .button { width: 100%; }
  .success-panel { padding-block: 48px; }
  .success-panel h2 { font-size: 2.25rem; }
  .surveys-index-page .survey-card:nth-child(n) { min-height: 0; }
}

@media (max-width: 480px) {
  .survey-toolbar .segmented-control { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .survey-toolbar .segmented-control button { width: 100%; padding-inline: 4px; font-size: 0.7rem; }
  .gate-actions .button { width: 100%; }
  .reference-code { width: 100%; text-align: left; }
}

@media (max-width: 380px) {
  .survey-topbar .brand__text { display: none; }
  .survey-layout__inner { width: calc(100% - 16px); }
  .survey-header-card,
  .consent-card,
  .question-card,
  .password-card,
  .success-panel { padding-right: 15px; padding-left: 15px; }
  .survey-header-card h1 { font-size: 1.8rem; }
  .question-card legend,
  .question-label { font-size: 0.96rem; }
}
