* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100vh; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: #f6f8fc; color: #0f172a; }
.container { max-width: 980px; margin: 0 auto; padding: 24px; background: #f6f8fc; }
h1 { margin: 8px 0 8px; font-size: 28px; }
.main-flow-title { text-align: center; margin: 18px 0 18px; }
.muted { color: #64748b; margin-top: 0; }
.card { background: #ffffff; border: 1px solid #e2e8f0; border-radius: 14px; padding: 16px; margin: 16px 0; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06); }
.card h2 { margin: 0 0 10px; font-size: 18px; }
label { display: block; margin: 10px 0; }
input, textarea, select { width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a; }
button { padding: 10px 12px; border-radius: 10px; border: 1px solid #cbd5e1; background: #ffffff; color: #0f172a; cursor: pointer; }
button.primary { background: #2563eb; border-color: #2563eb; color: #ffffff; }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
.row.center { justify-content: center; }
.centerText { text-align: center; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.out { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 10px; color: #0f172a; overflow: auto; }
.pill { background: #eff6ff; padding: 6px 10px; border-radius: 999px; border: 1px solid #bfdbfe; color: #1d4ed8; }
.countdown-pill { background: #fef3c7; border-color: #fcd34d; color: #92400e; font-weight: 600; }
.countdown-pill #chatCountdown { font-family: monospace; font-size: 15px; }
.checkbox { display: flex; gap: 10px; align-items: center; }
.checkbox input { width: auto; }

#step-consent .checkbox {
  font-size: 16px !important;
  line-height: 1.35;
  gap: 10px;
}

#step-consent .checkbox input {
  transform: scale(1.25);
  transform-origin: center;
  accent-color: #2563eb;
  outline: 2px solid #93c5fd;
  outline-offset: 1px;
  border-radius: 4px;
}

.consent-text {
  margin-bottom: 12px;
  text-align: left;
  color: #0f172a;
  line-height: 1.35;
}

.consent-text p {
  margin: 0 0 8px 0;
  font-size: 16px;
}

.consent-text ul {
  margin: 0 0 14px 24px;
  padding: 0;
  list-style: none;
}

.consent-text li {
  position: relative;
  margin: 0 0 4px 0;
  padding-left: 18px;
  font-size: 16px;
}

.consent-text li::before {
  content: "-";
  position: absolute;
  left: 0;
}

.consent-actions {
  width: 100%;
  margin-top: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
}

.consent-actions button {
  font-size: 22px;
  font-weight: 700;
  padding: 16px 32px;
  border-radius: 8px;
}

#btnBackWelcome,
#btnStart {
  font-size: 18px !important;
  font-weight: bold !important;
  padding: 16px 32px !important;
}
audio { width: 100%; margin: 10px 0; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; } }

.banner { border-radius: 14px; padding: 12px 14px; border: 1px solid #bfdbfe; background: #eff6ff; color: #0f172a; margin: 14px 0; white-space: pre-wrap; }
.banner.error { border-color: rgba(239, 68, 68, 0.6); background: rgba(239, 68, 68, 0.08); }

.kicker { font-size: 12px; color: #64748b; }
.stepTitle { font-size: 16px; font-weight: 600; margin-top: 2px; }

.progress-head {
  width: 100%;
}

.progress-steps {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: center;
  margin-top: 4px;
  width: 100%;
  gap: 6px;
}

.progress-step {
  font-size: 14px;
  font-weight: 400;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-step:first-child { text-align: left; }
.progress-step:last-child { text-align: right; }
.progress-step:not(:first-child):not(:last-child) { text-align: center; }

.progress-step.active {
  color: #1d4ed8;
  font-weight: 700;
}

.progress-step.done {
  color: #94a3b8;
  font-weight: 400;
}

.progress { height: 12px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin-top: 12px; }
.progressBar { height: 100%; background: linear-gradient(90deg, #2563eb, #1d4ed8); width: 0%; transition: width 200ms ease; }

.visuallyHidden { display: none; }

.chatPlaceholder {
  min-height: 120px;
  padding: 40px 20px;
  text-align: center;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #f8fafc;
  margin: 16px 0;
}

.chatActions {
	display: flex;
	gap: 10px;
	margin-top: 24px;
	align-items: center;
}

.chatMainCtaRow {
  display: flex;
  justify-content: center;
  margin: 18px 0 10px;
}

.chatStatusRow {
  margin: 18px 0 10px;
}

.chatStatusRow[hidden] {
  display: none !important;
}

#btnQuit,
#btnStartChatMainInline,
#btnSubmitSurvey,
#btnLikertSubpageNext,
#btnSurveyNext,
#btnSurveyQuit,
#btnSurveyQuit1b,
#btnSurveyQuit2 {
  font-size: 18px !important;
  font-weight: bold !important;
  padding: 16px 32px !important;
  white-space: nowrap;
}

.questionnaire-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.questionnaire-fields label {
  margin: 0;
  font-size: 17px;
}

.questionnaire-fields select {
  font-size: 16px;
  color: #64748b;
  padding: 12px 14px;
}

.questionnaire-fields textarea {
  font-size: 16px;
  padding: 12px 14px;
  min-height: 92px;
  resize: vertical;
}

.questionnaire-fields select:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px #93c5fd;
  border-color: #60a5fa;
}

.scale-hint {
  margin: 26px 0 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid #cbd5e1;
  font-weight: 600;
}

.open-feedback-item {
  margin: 12px 0 0 0;
}

.open-feedback-item textarea {
  margin-top: 6px;
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #0f172a;
  font-size: 16px;
}

.questionnaire-scale-list {
  display: grid;
  gap: 14px;
}

.question-item {
  display: grid;
  gap: 8px;
}

.question-item label {
  margin: 0;
  font-size: 17px;
  line-height: 1.35;
}

.questionnaire-group-divider {
  border: 0;
  border-top: 1px solid #d0d7de;
  margin: 12px 0 4px;
}

.questionnaire-scale {
  width: 100%;
}

.questionnaire-scroll {
  max-height: 62vh;
  overflow-y: auto;
  padding: 0 22px 0 3px;
  scrollbar-gutter: stable;
  box-sizing: border-box;
}

.native-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;
  border: 0 !important;
}

.custom-select {
  position: relative;
  margin-top: 6px;
}

.custom-select-btn {
  width: 100%;
  text-align: left;
  font-size: 16px;
  color: #64748b;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
}

.custom-select-btn::after {
  content: "▾";
  float: right;
  color: #64748b;
}

.custom-select.open .custom-select-btn {
  box-shadow: inset 0 0 0 2px #93c5fd;
  border-color: #60a5fa;
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 220px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
}

.custom-select-option {
  width: 100%;
  text-align: left;
  background: #fff;
  border: 0;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 12px;
  font-size: 15px;
  color: #475569;
}

.custom-select-option:last-child {
  border-bottom: 0;
}

.custom-select-option:hover {
  background: #eff6ff;
}

#step-survey:not([hidden]) {
  max-height: 72vh;
  display: flex;
  flex-direction: column;
}

#step-survey h2 {
  flex: 0 0 auto;
}

.questionnaire-submit-row {
  margin-top: 16px;
}

.questionnaire-actions {
  margin-top: 16px;
  width: 100%;
}

#surveyStatus {
  margin-top: 16px;
}

.scale-inline {
  display: grid;
  grid-template-columns: 130px auto 130px;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.scale-end {
  font-size: 14px;
  color: #64748b;
  white-space: nowrap;
}

.scale-points {
  display: grid;
  grid-template-columns: repeat(7, 56px);
  gap: 8px;
  position: relative;
  padding-top: 8px;
}

.scale-points::before {
  content: "";
  position: absolute;
  left: 2%;
  right: 2%;
  top: 18px;
  border-top: 2px solid #94a3b8;
  z-index: 0;
}

.scale-points label {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 0;
  font-size: 14px;
  color: #334155;
  position: relative;
  z-index: 1;
  background: #fff;
}

.scale-points input {
  width: auto;
  margin: 0 0 4px 0;
}

.single-choice-points {
  grid-template-columns: repeat(5, minmax(96px, 1fr));
}

.single-choice-points::before {
  display: none;
}

.single-choice-points label {
  min-height: 44px;
  justify-content: flex-start;
  text-align: center;
}

/* Fullscreen Pages */
.fullscreen-page {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.fullscreen-page[hidden] {
  display: none;
}

.fullscreen-content {
  text-align: center;
  max-width: 800px;
  width: 100%;
}

/* Welcome Page */
.welcome-page {
  background: linear-gradient(to bottom right, #2563eb, #9333ea);
  color: #ffffff;
}

.welcome-page .fullscreen-content {
  max-width: 1280px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: calc(100dvh - 48px);
}

.welcome-page .hero-title {
  font-size: clamp(20px, 2.6vw, 32px) !important;
  white-space: nowrap !important;
  line-height: 1.1;
  letter-spacing: -0.01em;
  font-weight: 800 !important;
  display: block;
  margin: 0 auto;
  color: #ffffff;
  text-align: center;
}

.hero-title {
  font-size: clamp(18px, 2.2vw, 28px);
  font-weight: bold;
  margin: 0 0 16px 0;
  color: #ffffff;
  white-space: nowrap;
  line-height: 1.2;
}

.welcome-info {
  flex: 1;
  overflow-y: auto;
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.8);
  padding: 20px 24px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  font-size: 16px;
  line-height: 1.36;
  text-align: left;
}

.welcome-info h2 {
  margin: 14px 0 4px;
  font-size: clamp(16px, 1.45vw, 19px);
  font-weight: 800;
  line-height: 1.15;
}

.welcome-info p {
  margin: 0 0 6px 0;
}

.welcome-info ol {
  margin: 4px 0 6px 24px;
  padding-left: 0;
}

.welcome-info li {
  margin-bottom: 2px;
}

.hero-subtitle {
  font-size: 20px;
  margin: 0 0 32px 0;
  opacity: 0.9;
}

.hero-button {
  padding: 16px 32px;
  background: #ffffff;
  color: #2563eb;
  font-weight: bold;
  font-size: 18px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
  align-self: center;
}

.hero-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

.hero-button.secondary {
  background: #ffffff;
  color: #2563eb;
}

.hero-button.secondary:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
}

/* Welcome page: Prolific ID input + Start button row */
.welcome-actions {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  width: 100%;
}

.prolific-id-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  min-width: 360px;
  margin-right: auto;
}

.prolific-id-field label {
  font-size: 18px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 0.02em;
  text-align: left;
}

.prolific-id-field input {
  height: 57px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  font-size: 16px;
  font-family: inherit;
  min-width: 360px;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.12);
}

.prolific-id-field input:focus {
  outline: none;
  border-color: #ffffff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.prolific-id-field input.invalid {
  border-color: #fecaca;
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.35);
}

.welcome-actions .hero-button {
  align-self: flex-end;
  margin: 0 0 0 auto;
  min-height: 57px;
}

.prolific-id-error {
  margin: 10px 0 0 0;
  color: #fecaca;
  font-weight: 600;
  font-size: 15px;
  text-align: center;
}

/* Completion code block on the thank-you page */
.completion-code-block {
  margin: 28px auto 0;
  padding: 24px 28px;
  background: rgba(255, 255, 255, 0.95);
  color: #111827;
  border-radius: 14px;
  max-width: 520px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  text-align: center;
}

.completion-code-label {
  margin: 0 0 8px 0;
  font-size: 15px;
  color: #4b5563;
  font-weight: 600;
}

.completion-code {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 32px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #2563eb;
  user-select: all;
}

.completion-code-hint {
  margin: 12px 0 0 0;
  font-size: 14px;
  color: #4b5563;
}

/* Thank You Page */
.thankyou-page {
  background: linear-gradient(to bottom right, #2563eb, #9333ea);
  color: #ffffff;
}

.thankyou-page .hero-title {
  color: #ffffff;
}

.thankyou-page .hero-subtitle {
  color: #ffffff;
  opacity: 1;
}

.redirect-info {
  margin-top: 24px;
  font-size: 18px;
  color: #ffffff;
}

.countdown-number {
  font-weight: bold;
  color: #ffffff;
  font-size: 24px;
}

@media (max-width: 768px) {
  .fullscreen-page {
    align-items: flex-start;
    justify-content: flex-start;
    overflow-y: auto;
    padding: 14px 14px calc(14px + env(safe-area-inset-bottom));
  }

  .welcome-page .fullscreen-content {
    min-height: calc(100dvh - 28px - env(safe-area-inset-bottom));
    max-height: none;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .welcome-page .hero-title {
    font-size: clamp(18px, 5vw, 24px) !important;
  }

  .welcome-info {
    font-size: 16px;
    padding: 16px 14px;
  }

  .welcome-info h2 {
    font-size: 18px;
  }

  .hero-subtitle {
    font-size: 16px;
  }
  .hero-button {
    font-size: 16px;
    padding: 12px 24px;
  }

  .welcome-page .hero-button {
    width: 100%;
    margin-bottom: max(6px, env(safe-area-inset-bottom));
  }
}

/* Phase transition overlay — styled as a toast notification */
.phase-transition-overlay {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 24px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
  z-index: 100;
  font-size: 0.95rem;
  color: #64748b;
}
.phase-transition-overlay[hidden] { display: none; }
.phase-transition-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Make chat section position relative for overlay */
#step-chat { position: relative; }

/* Disclosure completion reminder */
.disclosure-reminder {
  text-align: center;
  color: #2563eb;
  font-weight: 500;
  margin: 12px 0 4px;
  font-size: 0.95rem;
}
.disclosure-reminder[hidden] { display: none; }

/* Task Instructions (pre-chat) */
.task-heading {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
}

.task-heading-reminder {
  font-size: 18px;
  margin: 0 0 8px;
}

.task-instructions-text {
  margin-bottom: 18px;
  text-align: left;
  color: #0f172a;
  line-height: 1.5;
  font-size: 17px;
  padding: 12px 4px;
}

.chat-task-reminder {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #f8fbff;
  color: #0f172a;
  line-height: 1.5;
  font-size: 16px;
}

.chat-task-reminder p {
  margin: 0;
}

.audio-check-card {
  margin: 8px 0 24px;
  padding: 18px;
  border: 1px solid #dbeafe;
  border-radius: 14px;
  background: #f8fbff;
}

.audio-check-card h3 {
  margin: 0 0 8px;
  font-size: 20px;
}

.audio-check-intro {
  margin: 0 0 16px;
  color: #475569;
  font-size: 15px;
}

.audio-check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.audio-check-item {
  padding: 16px;
  border: 1px solid #dbeafe;
  border-radius: 12px;
  background: #ffffff;
}

.audio-check-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
}

.check-light {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #cbd5e1;
  box-shadow: 0 0 0 3px rgba(203, 213, 225, 0.35);
}

.check-light.testing {
  background: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.check-light.failed {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.16);
}

.check-light.passed {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.audio-check-status {
  min-height: 24px;
  margin: 10px 0 14px;
  color: #475569;
  font-size: 15px;
}

.audio-check-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.mic-level-meter {
  height: 10px;
  margin: 0 0 14px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.mic-level-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #60a5fa, #22c55e);
  transition: width 80ms linear;
}

.audio-check-ready {
  margin: 16px 0 0;
  color: #15803d;
  font-weight: 700;
}

.instr-actions button {
  font-size: 18px !important;
  font-weight: bold !important;
  padding: 16px 32px !important;
}

.instr-actions .primary:disabled {
  background: #cbd5e1 !important;
  border-color: #cbd5e1 !important;
  color: #ffffff !important;
  opacity: 1;
}

@media (max-width: 860px) {
  .audio-check-grid {
    grid-template-columns: 1fr;
  }
}
