: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, input, textarea { font: inherit; }

button {
  align-items: center;
  background: var(--accent);
  border: 0;
  border-radius: 7px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
}

button:hover:not(:disabled) { background: var(--accent-strong); }
button:disabled { cursor: not-allowed; opacity: 0.45; }
button.secondary { background: #e8edf2; color: #24313f; }
.button-link {
  align-items: center;
  background: var(--accent);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  min-height: 46px;
  padding: 0 20px;
  text-decoration: none;
}

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

input[type="text"], textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 44px;
  padding: 9px 11px;
  width: 100%;
}

textarea { resize: vertical; }

.app-shell { margin: 0 auto; max-width: 1180px; padding: 28px 20px 56px; }
.header { margin-bottom: 20px; }
.header h1, .panel h2 { margin: 0; }
.header h1 { font-size: clamp(32px, 5vw, 54px); line-height: 1.1; }
.eyebrow { color: var(--accent); font-size: 13px; font-weight: 900; margin: 0 0 7px; text-transform: uppercase; }

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

.panel-heading { align-items: start; display: flex; gap: 20px; justify-content: space-between; margin-bottom: 22px; }
.panel-heading p { color: var(--ink-muted); margin: 8px 0 0; }
.setup-status { background: #fff7e8; border: 1px solid #f0d2a2; border-radius: 999px; color: var(--amber); font-size: 13px; font-weight: 900; padding: 8px 13px; white-space: nowrap; }
.setup-status[data-ready="true"] { background: #eaf7ef; border-color: #bde1cb; color: var(--green); }

.onboarding-progress { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); margin-bottom: 28px; }
.step-chip { align-items: center; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 12px; min-height: 64px; padding: 12px 14px; }
.step-chip span { align-items: center; background: #dce4ea; border-radius: 50%; display: inline-flex; height: 34px; justify-content: center; width: 34px; }
.step-chip.active { background: #eef8f8; border-color: #8bc1c5; }
.step-chip.active span, .step-chip.complete span { background: var(--accent); color: #fff; }

.setup-step { display: none; }
.setup-step.active { display: block; }
.step-kicker { color: var(--accent); font-size: 13px; font-weight: 900; margin: 0 0 6px; text-transform: uppercase; }
.setup-step h3 { font-size: 20px; margin: 0 0 16px; }

.participant-instructions, .notice {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #2f3b48;
  line-height: 1.55;
  margin-bottom: 18px;
  padding: 17px;
}
.participant-instructions p, .notice p { margin: 0 0 10px; }
.participant-instructions p:last-child, .notice p:last-child { margin-bottom: 0; }
.participant-instructions ol { margin: 0 0 10px 22px; padding: 0; }
.participant-instructions li { margin: 6px 0; }

.consent-options { display: grid; gap: 12px; }
.check-card { align-items: center; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; display: flex; font-weight: 750; gap: 12px; min-height: 58px; padding: 14px; }
.check-card:has(input:checked) { background: #eef8f8; border-color: var(--accent); }
.check-card input, .inline-check input { height: 20px; min-height: 0; width: 20px; }
.detected-note { background: #eaf7ef; border-radius: 7px; color: var(--green); font-weight: 800; margin: 16px 0 0; padding: 11px 13px; }
.preview-id { display: grid; font-weight: 750; gap: 7px; margin-top: 16px; max-width: 420px; }

.background-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(240px, 1fr)); margin-top: 16px; }
.question-card { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; display: grid; font-weight: 750; gap: 8px; margin: 0; padding: 15px; }
.question-card.full-width { grid-column: 1 / -1; }
.question-card legend { font-size: 14px; font-weight: 850; padding: 0 4px; }
.stacked-options { display: grid; gap: 8px; }
.stacked-options.two-columns { grid-template-columns: repeat(2, 1fr); }
.stacked-options label { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; display: flex; gap: 8px; min-height: 40px; padding: 8px 10px; }
.stacked-options label:has(input:checked) { background: #eef8f8; border-color: var(--accent); }
.detail-label { display: grid; gap: 7px; margin-top: 8px; }

.number-options, .rating-options { display: grid; gap: 8px; grid-template-columns: repeat(9, minmax(40px, 1fr)); margin: 8px 0 10px; }
.number-options { grid-template-columns: repeat(6, minmax(40px, 1fr)); }
.number-options label, .rating-options label { align-items: center; background: #fff; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; display: flex; font-weight: 900; justify-content: center; min-height: 44px; }
.number-options input, .rating-options input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.number-options label:has(input:checked), .rating-options label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }
.scale-anchors { color: var(--ink-muted); display: flex; font-size: 12px; font-weight: 750; justify-content: space-between; }

.scale-summary-grid, .ready-summary { display: grid; gap: 14px; grid-template-columns: repeat(3, 1fr); }
.scale-summary-grid > div, .ready-summary > div { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; padding: 15px; }
.scale-summary-grid span, .ready-summary span { color: var(--ink-muted); display: block; font-size: 12px; font-weight: 900; margin-bottom: 7px; text-transform: uppercase; }
.scale-summary-grid p { line-height: 1.45; margin: 0 0 9px; }

.onboarding-controls, .actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 22px; }
.onboarding-controls { border-top: 1px solid var(--line); padding-top: 18px; }

.validation-message { background: #fff4f2; border: 1px solid #d8796f; border-radius: 7px; color: #8a2d25; font-weight: 750; margin: 12px 0 18px; padding: 11px 13px; }
[aria-invalid="true"] { border-color: #b73d32 !important; box-shadow: 0 0 0 2px rgba(183, 61, 50, 0.15); }

.task-topbar { align-items: start; display: flex; gap: 20px; justify-content: space-between; }
.task-topbar strong { background: #eef8f8; border-radius: 999px; color: var(--accent-strong); padding: 8px 12px; }
.progress-track { background: #e5ebf0; border-radius: 999px; height: 10px; margin: 20px 0 8px; overflow: hidden; }
#practice-progress, #main-progress { background: var(--accent); height: 100%; transition: width 180ms ease; width: 0; }
.progress-text { color: var(--ink-muted); font-size: 13px; font-weight: 750; text-align: right; }
.stimulus-area { align-items: center; background: #f9fbfc; border: 1px solid var(--line); border-radius: 8px; display: grid; gap: 13px; justify-items: center; margin: 22px 0; min-height: 160px; padding: 28px; }
.stimulus-area p { color: var(--ink-muted); margin: 0; }
.play-button { font-size: 19px; min-height: 58px; min-width: 180px; }
.dictation-field { display: grid; font-size: 16px; font-weight: 850; gap: 8px; }
.dictation-field input { font-size: 21px; min-height: 54px; }
.inline-check { align-items: center; color: var(--ink-muted); display: flex; font-weight: 750; gap: 8px; margin-top: 12px; }
.rating-block { border: 1px solid var(--line); border-radius: 8px; margin: 18px 0; padding: 17px; }
.rating-block legend { font-size: 18px; font-weight: 900; padding: 0 7px; }
.rating-block p { color: var(--ink-muted); }
.practice-feedback { background: #eef7f8; border: 1px solid #b7d8dc; border-radius: 8px; color: #183a3e; line-height: 1.55; padding: 18px; }
.practice-feedback h3 { margin-top: 0; }
#feedback-replay-status { color: var(--ink-muted); font-size: 14px; margin-left: 10px; }
.complete-panel { text-align: left; }
.complete-panel > p:not(.eyebrow) { color: var(--ink-muted); }
.gate-panel code { background: #edf3f5; border-radius: 4px; padding: 2px 5px; }

.hidden { display: none !important; }

.distractor-problems { display: grid; gap: 12px; margin-top: 20px; max-width: 520px; }
.distractor-problem {
  align-items: center;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  font-size: 20px;
  font-weight: 850;
  gap: 18px;
  grid-template-columns: 1fr 140px;
  padding: 14px 16px;
}
.distractor-problem input {
  border: 1px solid var(--line);
  border-radius: 7px;
  min-height: 44px;
  padding: 8px 10px;
  width: 100%;
}
.completion-code { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.admin-actions, .admin-maintenance { display: flex; flex-wrap: wrap; gap: 12px; margin: 18px 0; }
.admin-maintenance { align-items: end; }
.admin-maintenance label { display: grid; font-weight: 750; gap: 6px; min-width: 210px; }
.admin-maintenance input { border: 1px solid var(--line); border-radius: 7px; min-height: 44px; padding: 8px 10px; }
.admin-grid, .condition-grid { display: grid; gap: 14px; grid-template-columns: repeat(4, 1fr); margin: 20px 0; }
.admin-card, .condition-card { background: var(--panel-soft); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
.admin-card span, .condition-card span, .condition-card small { color: var(--ink-muted); display: block; }
.admin-card strong, .condition-card strong { display: block; font-size: 24px; margin-top: 6px; }
.condition-card small { margin: 7px 0; }
.mini-track { background: #dce4ea; border-radius: 999px; height: 7px; overflow: hidden; }
.mini-track i { background: var(--green); display: block; height: 100%; }
button.danger { background: #9a342d; }
.log { background: #18222d; border-radius: 8px; color: #d9e5ef; min-height: 100px; overflow: auto; padding: 16px; white-space: pre-wrap; }
.active-attempts { display: grid; gap: 9px; margin-bottom: 22px; }
.active-attempt { align-items: center; border: 1px solid var(--line); border-radius: 8px; display: flex; gap: 14px; justify-content: space-between; padding: 12px 14px; }
.active-attempt small { color: var(--ink-muted); display: block; margin-top: 5px; overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .app-shell { padding: 18px 12px 38px; }
  .panel { padding: 20px 16px; }
  .panel-heading { display: block; }
  .setup-status { display: inline-block; margin-top: 14px; }
  .onboarding-progress { grid-template-columns: repeat(2, 1fr); }
  .background-grid, .scale-summary-grid, .ready-summary, .admin-grid, .condition-grid { grid-template-columns: 1fr; }
  .question-card.full-width { grid-column: auto; }
  .rating-options { grid-template-columns: repeat(5, 1fr); }
  .task-topbar { display: block; }
  .task-topbar strong { display: inline-block; margin-top: 12px; }
  .distractor-problem { grid-template-columns: 1fr 110px; }
}
