:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #1f2933;
  --panel: #ffffff;
  --panel-soft: #f8fafb;
  --ink-muted: #5b6573;
  --line: #d6dde5;
  --accent: #166b70;
  --accent-strong: #0f4f53;
  --amber: #a35f00;
  --green: #247449;
  --shadow: 0 16px 36px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
.button-link,
input,
select {
  font: inherit;
}

button,
.button-link {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  min-height: 44px;
  padding: 0 18px;
  text-decoration: none;
  transition: background 140ms ease, box-shadow 140ms ease, transform 140ms ease;
}

button:hover:not(:disabled),
.button-link:hover {
  background: var(--accent-strong);
  box-shadow: 0 8px 20px rgba(22, 107, 112, 0.16);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.secondary,
.button-link.secondary {
  background: #e8edf2;
  color: #24313f;
}

button.secondary:hover:not(:disabled),
.button-link.secondary:hover {
  background: #d5dee8;
}

input[type="text"],
input[type="number"],
select {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 8px 10px;
  width: 100%;
}

input[type="number"] {
  appearance: textfield;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(22, 107, 112, 0.25);
  outline-offset: 2px;
}

.app-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 28px 20px 56px;
}

.header {
  align-items: end;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  margin-bottom: 20px;
}

.header h1,
.panel h2 {
  letter-spacing: 0;
  margin: 0;
}

.header h1 {
  font-size: 34px;
  line-height: 1.15;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.version {
  color: var(--ink-muted);
  font-size: 13px;
  white-space: nowrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-top: 18px;
  padding: 24px;
}

.panel-heading {
  align-items: start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.panel-heading p {
  margin: 8px 0 0;
}

.panel-heading p,
.audio-state,
.complete-panel p,
.break-panel p {
  color: var(--ink-muted);
}

.setup-status {
  background: #fff7e8;
  border: 1px solid #f0d2a2;
  border-radius: 999px;
  color: var(--amber);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 12px;
  white-space: nowrap;
}

.setup-status[data-ready="true"] {
  background: #eaf7ef;
  border-color: #bde1cb;
  color: var(--green);
}

.status-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 22px;
}

.status-grid div,
.trial-rail div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.status-grid span,
.trial-rail span {
  color: var(--ink-muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.status-grid strong,
.trial-rail strong {
  color: #24313f;
  display: block;
  font-size: 22px;
  line-height: 1.1;
}

.setup-layout {
  display: grid;
  gap: 20px;
}

.setup-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.setup-section h3 {
  font-size: 15px;
  margin: 0 0 12px;
}

.form-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.participant-instructions {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #2f3b48;
  line-height: 1.55;
  margin-bottom: 16px;
  padding: 16px;
}

.participant-instructions p {
  margin: 0 0 10px;
}

.participant-instructions p:last-child {
  margin-bottom: 0;
}

.participant-instructions ol {
  margin: 0 0 10px 20px;
  padding: 0;
}

.participant-instructions li {
  margin: 5px 0;
}

.turnstile-widget {
  margin-bottom: 16px;
  min-height: 65px;
}

body.participant-mode .researcher-only {
  display: none !important;
}

body:not(.participant-mode) .participant-only {
  display: none !important;
}

body.participant-mode .app-shell {
  max-width: 920px;
}

body.participant-mode .form-grid {
  grid-template-columns: minmax(220px, 360px);
}

body.participant-mode #participant-id-field.hidden {
  display: none !important;
}

body.participant-mode .setup-step {
  display: none;
}

body.participant-mode .setup-step.active {
  display: block;
}

body.participant-mode .rating-workspace {
  grid-template-columns: minmax(0, 1fr);
}

body.participant-mode .trial-rail,
body.participant-mode #pause-btn {
  display: none !important;
}

.onboarding-progress {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 0 22px;
}

.onboarding-step-chip {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-muted);
  display: flex;
  gap: 10px;
  min-height: 48px;
  padding: 10px;
}

.onboarding-step-chip span {
  align-items: center;
  background: #e8edf2;
  border-radius: 999px;
  color: #24313f;
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 900;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.onboarding-step-chip strong {
  display: block;
  font-size: 13px;
  line-height: 1.2;
}

.onboarding-step-chip.active {
  background: #eef8f8;
  border-color: #9fc9cc;
  color: var(--accent-strong);
}

.onboarding-step-chip.active span,
.onboarding-step-chip.complete span {
  background: var(--accent);
  color: white;
}

.onboarding-step-chip.complete {
  border-color: #bdd7d9;
  color: #2f3b48;
}

.step-kicker {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

.step-copy {
  color: var(--ink-muted);
  margin: -4px 0 16px;
}

.prolific-detected-note {
  background: #eaf7ef;
  border: 1px solid #bde1cb;
  border-radius: 8px;
  color: var(--green);
  font-weight: 800;
  margin: 0 0 16px;
  padding: 12px 14px;
}

.scale-summary-grid,
.ready-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.scale-summary-grid div,
.ready-summary div {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 88px;
  padding: 14px;
}

.scale-summary-grid span,
.ready-summary span {
  color: var(--ink-muted);
  display: block;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 8px;
}

.scale-summary-grid strong,
.ready-summary strong {
  color: #24313f;
  display: block;
  font-size: 15px;
  line-height: 1.35;
}

.onboarding-controls {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 22px;
  padding-top: 18px;
}

body.participant-mode .setup-step[data-onboarding-step="ready"] .actions {
  margin-top: 20px;
}

body.participant-mode .setup-step[data-onboarding-step="ready"] #start-btn {
  min-width: 180px;
}

.familiarity-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  margin-top: 16px;
}

.familiarity-field {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
}

.familiarity-field legend {
  color: #2f3b48;
  font-size: 14px;
  font-weight: 800;
  padding: 0 4px;
}

.familiarity-options {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(6, minmax(34px, 1fr));
  margin: 8px 0 10px;
}

.familiarity-options label {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  font-size: 15px;
  font-weight: 800;
  justify-content: center;
  min-height: 40px;
  padding: 6px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.familiarity-options input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.familiarity-options label:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.familiarity-anchors {
  color: var(--ink-muted);
  display: flex;
  font-size: 12px;
  font-weight: 700;
  justify-content: space-between;
  line-height: 1.25;
}

.familiarity-anchors span:last-child {
  text-align: right;
}

label {
  color: #2f3b48;
  display: grid;
  font-size: 14px;
  font-weight: 700;
  gap: 7px;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 9px;
}

.checkbox-label input {
  inline-size: auto;
}

.upload-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.remote-card {
  background: #f5f9fa;
  border: 1px solid #c7d8dc;
  border-radius: 8px;
  padding: 16px;
}

.remote-heading,
.participant-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
}

.participant-actions {
  justify-content: flex-start;
  margin-top: 12px;
}

.source-option {
  min-height: 44px;
}

.source-summary {
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
}

.custom-field {
  margin-top: 12px;
  max-width: 560px;
}

.participant-grid {
  background: #f7fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 12px;
  max-height: 240px;
  overflow: auto;
  padding: 12px;
}

.participant-grid.empty {
  color: var(--ink-muted);
  display: block;
  font-weight: 700;
}

.participant-option {
  align-items: center;
  background: #ffffff;
  border: 1px solid #dce3eb;
  border-radius: 6px;
  display: flex;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
}

.participant-option input {
  inline-size: auto;
}

.participant-option span {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 700;
  margin-left: auto;
}

.remote-card small {
  color: var(--ink-muted);
  display: block;
  font-weight: 600;
  line-height: 1.4;
  margin-top: 10px;
}

#prepare-remote-btn {
  margin-top: 12px;
}

.upload-card {
  background: var(--panel-soft);
  border: 1px dashed #b9c4cf;
  border-radius: 8px;
  padding: 16px;
}

.upload-card span {
  font-size: 15px;
}

.upload-card small {
  color: var(--ink-muted);
  font-weight: 500;
  line-height: 1.4;
}

.scale-details {
  border-top: 1px solid var(--line);
  margin-top: 22px;
  padding-top: 16px;
}

.scale-details summary {
  cursor: pointer;
  font-weight: 800;
}

.anchor-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.anchor-grid h3,
.anchor-grid p {
  margin: 0 0 8px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
}

.log {
  background: #101820;
  border-radius: 8px;
  color: #d7e6ee;
  font-size: 13px;
  line-height: 1.5;
  margin: 18px 0 0;
  max-height: 220px;
  overflow: auto;
  padding: 14px;
  white-space: pre-wrap;
}

.log:empty {
  display: none;
}

.hidden {
  display: none !important;
}

.task-topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.progress-track {
  background: #e5ebf0;
  border-radius: 999px;
  height: 10px;
  margin: 18px 0 8px;
  overflow: hidden;
}

#progress-fill {
  background: var(--accent);
  height: 100%;
  transition: width 180ms ease;
  width: 0;
}

.progress-text {
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 22px;
  text-align: right;
}

.rating-workspace {
  align-items: start;
  display: grid;
  gap: 22px;
  grid-template-columns: 180px minmax(0, 1fr);
}

.trial-rail {
  display: grid;
  gap: 10px;
  position: sticky;
  top: 20px;
}

.trial-rail strong {
  font-size: 20px;
}

.response-stack {
  min-width: 0;
}

.stimulus-area {
  align-items: center;
  background: #f9fbfc;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  justify-items: center;
  margin-bottom: 22px;
  min-height: 150px;
  padding: 26px;
}

.play-button {
  font-size: 20px;
  min-height: 58px;
  min-width: 180px;
}

.dictation-box {
  margin-bottom: 20px;
}

.dictation-box input {
  font-size: 22px;
  min-height: 54px;
}

.dictation-unidentified {
  align-items: center;
  color: var(--ink-muted);
  display: flex;
  font-size: 14px;
  font-weight: 700;
  gap: 8px;
  margin-top: 10px;
}

.dictation-unidentified input {
  height: 18px;
  min-height: 0;
  width: 18px;
}

.scale-block {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 18px 0;
  padding: 16px;
}

.scale-block legend {
  font-size: 17px;
  font-weight: 800;
  padding: 0 8px;
}

.scale-endpoints {
  align-items: center;
  color: var(--ink-muted);
  display: flex;
  font-size: 14px;
  font-weight: 700;
  justify-content: space-between;
  margin: 0 0 12px;
  gap: 10px;
}

.scale-options {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(9, minmax(42px, 1fr));
}

.scale-options label {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  font-size: 15px;
  font-weight: 800;
  justify-content: center;
  min-height: 44px;
  padding: 6px;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.scale-block.disabled {
  background: #f8fafb;
}

.scale-block.disabled .scale-options label:not(:has(input:checked)) {
  color: #8993a0;
  cursor: not-allowed;
  opacity: 0.62;
}

.scale-options input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.scale-options label:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.practice-feedback {
  background: #eef7f8;
  border: 1px solid #b7d8dc;
  border-radius: 8px;
  color: #183a3e;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.5;
  margin-top: 18px;
  padding: 14px;
  white-space: pre-line;
}

.practice-reason {
  background: #fff7e8;
  border: 1px solid #f0d2a2;
  border-radius: 8px;
  margin-top: 14px;
  padding: 14px;
}

.practice-reason textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 84px;
  padding: 8px 10px;
  resize: vertical;
  width: 100%;
}

.completion-code-box {
  background: #f5f9fa;
  border: 1px solid #c7d8dc;
  border-radius: 8px;
  display: inline-grid;
  gap: 6px;
  margin-top: 12px;
  min-width: min(100%, 360px);
  padding: 16px;
}

.completion-code-box span {
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.completion-code-box strong {
  color: #17242f;
  font-size: 28px;
  letter-spacing: 0.04em;
}

.prolific-return-link {
  align-items: center;
  background: var(--accent);
  border-radius: 6px;
  color: #ffffff;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  margin-top: 14px;
  min-height: 44px;
  padding: 0 18px;
  text-decoration: none;
}

.prolific-return-link:focus,
.prolific-return-link:hover {
  background: #1f5e66;
}

.trial-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 22px;
}

.break-panel,
.distractor-panel,
.complete-panel {
  text-align: center;
}

.distractor-problems {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 22px auto 14px;
  max-width: 720px;
  text-align: left;
}

.distractor-problem {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.distractor-problem label {
  display: grid;
  gap: 8px;
}

.distractor-problem span {
  color: #24313f;
  font-size: 18px;
  font-weight: 800;
}

.distractor-status {
  color: var(--ink-muted);
  min-height: 24px;
}

.admin-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
}

.admin-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.admin-card span {
  color: var(--ink-muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 5px;
}

.admin-card strong {
  display: block;
  font-size: 28px;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.admin-token {
  max-width: 520px;
}

.admin-maintenance {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.admin-maintenance label {
  max-width: 220px;
}

@media (max-width: 820px) {
  .header {
    align-items: start;
    flex-direction: column;
  }

  .panel-heading {
    align-items: start;
    flex-direction: column;
  }

  .form-grid,
  .upload-grid,
  .participant-grid,
    .onboarding-progress,
    .anchor-grid,
    .familiarity-grid,
    .scale-summary-grid,
    .ready-summary,
    .status-grid,
    .distractor-problems,
    .rating-workspace {
      grid-template-columns: 1fr;
    }

  .trial-rail {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    position: static;
  }

  .admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .scale-options {
    grid-template-columns: repeat(5, minmax(42px, 1fr));
  }

  .progress-text {
    text-align: left;
  }
}

@media (max-width: 560px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}
