:root {
  color-scheme: light;
  --ink: #17221d;
  --muted: #637069;
  --line: #dce4df;
  --paper: #ffffff;
  --wash: #f3f7f4;
  --accent: #176b4b;
  --accent-dark: #0f5038;
  --milo: #e9f4ef;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--wash); }
button, input, textarea, select { font: inherit; }
.shell { width: min(900px, 100%); margin: 0 auto; padding: max(24px, env(safe-area-inset-top)) 24px max(36px, env(safe-area-inset-bottom)); }
header { margin-bottom: 18px; }
h1 { margin: 4px 0 10px; font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.15; }
h2 { margin-top: 0; }
.eyebrow, .label { color: var(--muted); font-size: .84rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.participant-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.participant-header .eyebrow { margin: 0; }
.status-row { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: .92rem; }
.connection { color: #b3bcb7; font-size: 1rem; font-weight: 700; line-height: 1; }
.connection.offline { color: #d6331f; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: clamp(22px, 5vw, 44px); box-shadow: 0 8px 28px rgb(23 34 29 / 6%); }
.card + .card { margin-top: 18px; }
.centered { min-height: 320px; display: grid; place-content: center; text-align: center; }
#wait p { margin: 0; font-size: 1.15rem; line-height: 1.5; }
.dots span { animation: dot 1.4s infinite both; }
.dots span:nth-child(2) { animation-delay: .2s; }
.dots span:nth-child(3) { animation-delay: .4s; }
@keyframes dot { 0%, 80%, 100% { opacity: 0; } 40% { opacity: 1; } }
[hidden] { display: none !important; }
.context { margin: 4px 0 24px; color: var(--muted); font-size: 1.2rem; font-weight: 400; line-height: 1.55; }
.context + hr { margin: 0 0 28px; border: 0; border-top: 1px solid var(--line); }
.survey-introduction { color: var(--ink); }
.survey-introduction p { margin: 0; }
.survey-introduction p + p { margin-top: 16px; }
.survey-introduction strong { font-weight: 700; }
.question-title { margin: 4px 0 24px; font-size: clamp(1.62rem, 3.6vw, 2.16rem); font-weight: 400; line-height: 1.3; }
.question-title strong { font-weight: 800; color: var(--accent); }
fieldset { border: 0; margin: 0 0 36px; padding: 0; }
legend { width: 100%; margin-bottom: 12px; font-size: 1.2rem; font-weight: 400; line-height: 1.4; }
legend.seat-legend { font-size: 1.6rem; font-weight: 800; color: var(--accent); }
.choices { display: grid; gap: 10px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: #f0faf5; }
input[type="radio"], input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--accent); flex: 0 0 auto; }
.multiple-choices input[type="checkbox"] { appearance: none; border: 1px solid #767676; border-radius: 50%; background: var(--paper); }
.multiple-choices input[type="checkbox"]:checked { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 5px, var(--paper) 6px); }
.scale { display: grid; grid-template-columns: repeat(var(--columns, 7), minmax(44px, 1fr)); gap: 7px; }
.scale[data-columns="5"] { --columns: 5; }
.scale[data-columns="7"] { --columns: 7; }
.scale[data-columns="11"] { --columns: 11; }
.scale .choice { display: grid; place-items: center; min-width: 0; padding: 9px 3px; text-align: center; }
.scale-label { display: block; color: var(--muted); font-size: .72rem; line-height: 1.1; min-height: 1.6em; }
textarea { width: 100%; min-height: 180px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; resize: vertical; line-height: 1.5; }
textarea:focus { outline: 3px solid rgb(23 107 75 / 16%); border-color: var(--accent); }
.other-answer { min-height: 80px; }
/* Five 48px rows are visible; the middle one (the tinted band) is the answer. */
.number-wheel { box-sizing: content-box; width: min(100% - 2px, 240px); height: 240px; margin: 0 auto; overflow-y: scroll; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(transparent 96px, #f0faf5 96px, #f0faf5 144px, transparent 144px); touch-action: pan-y; }
.number-wheel::-webkit-scrollbar { display: none; }
.number-wheel::before, .number-wheel::after { display: block; height: 96px; content: ""; }
.number-wheel:focus-visible { outline: 3px solid rgb(23 107 75 / 16%); border-color: var(--accent); }
.wheel-row { display: grid; place-items: center; height: 48px; color: var(--muted); font-size: 1.5rem; font-variant-numeric: tabular-nums; scroll-snap-align: center; cursor: pointer; user-select: none; }
.wheel-row.selected { color: var(--ink); font-weight: 700; }
/* Marked when Next is pressed with this question unanswered; cleared once answered. */
.unanswered { border-radius: 14px; outline: 2px solid rgb(214 51 31 / 30%); outline-offset: 8px; }
textarea.unanswered, .number-wheel.unanswered { outline-offset: 2px; }
.readonly { padding: 14px 16px; border-radius: 12px; background: var(--wash); font-weight: 700; }
.sum-rows { display: grid; gap: 10px; }
.sum-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; }
.sum-name { font-size: 1.2rem; line-height: 1.35; }
.sum-row input { width: 5.5ch; padding: 10px 8px; border: 1px solid var(--line); border-radius: 10px; font-size: 1.15rem; font-variant-numeric: tabular-nums; text-align: center; flex: 0 0 auto; }
.sum-row input:focus { outline: 3px solid rgb(23 107 75 / 16%); border-color: var(--accent); }
.sum-total { margin: 6px 0 0; color: var(--muted); font-size: 1.05rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-total.balanced { color: var(--accent); }
.sum-total.over { color: #a33b2b; }
.final-note { margin: 28px 0 0; font-size: 1rem; }
.ios-image { display: block; width: 100%; height: auto; margin: 0 0 20px; }
.actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 28px; }
button { min-height: 48px; border: 0; border-radius: 12px; padding: 10px 20px; background: var(--accent); color: #fff; font-weight: 750; cursor: pointer; }
button:hover { background: var(--accent-dark); }
button:disabled { cursor: not-allowed; opacity: .45; }
button:focus-visible { outline: 3px solid rgb(23 107 75 / 30%); outline-offset: 2px; }
button.secondary { color: var(--ink); background: var(--wash); border: 1px solid var(--line); }
button.autofill { margin-right: auto; border-style: dashed; }
.feedback { min-height: 1.4em; color: #a33b2b; }
.turns { display: grid; gap: 10px; margin-bottom: 18px; }
.turn { padding: 13px 15px; border-left: 4px solid var(--line); background: var(--wash); border-radius: 0 10px 10px 0; line-height: 1.45; }
.turn strong { display: block; margin-bottom: 3px; }
.turn.milo { border-color: var(--accent); background: var(--milo); }
.remember { margin: 20px 0 26px; }
/* Fixed survey progress bar; the shell's bottom padding keeps content clear of it. */
body:has(.survey-progress:not([hidden])) .shell { padding-bottom: calc(max(36px, env(safe-area-inset-bottom)) + 56px); }
.survey-progress { position: fixed; inset: auto 0 0; z-index: 10; padding: 18px 24px max(16px, env(safe-area-inset-bottom)); background: linear-gradient(to top, var(--wash) 65%, rgb(243 247 244 / 0)); pointer-events: none; }
.survey-progress-inner { display: flex; align-items: center; gap: 14px; width: min(852px, 100%); margin: 0 auto; }
.survey-progress-track { position: relative; flex: 1; height: 14px; border-radius: 999px; background: #dde7e1; box-shadow: inset 0 1px 2px rgb(23 34 29 / 10%); overflow: hidden; }
.survey-progress-fill { position: relative; width: 0; height: 100%; border-radius: inherit; overflow: hidden; background: linear-gradient(90deg, #0f5038 0%, #176b4b 25%, #25a36a 60%, #7fd67a 85%, #c6f07a 100%); box-shadow: 0 0 12px rgb(37 163 106 / 45%); transition: width .6s cubic-bezier(.22, 1, .36, 1); }
.survey-progress-label { min-width: 4ch; color: var(--accent); font-size: .95rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.confirm { width: min(520px, calc(100% - 32px)); padding: clamp(22px, 5vw, 34px); border: 0; border-radius: 20px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 60px rgb(23 34 29 / 25%); }
.confirm::backdrop { background: rgb(23 34 29 / 45%); }
.confirm-text { margin: 0 0 8px; font-size: 1.2rem; font-weight: 700; line-height: 1.5; }
.confirm .actions { margin-top: 12px; }
.researcher-shell { width: min(1050px, 100%); }
.workflow-card h2 { margin-bottom: 22px; }
.workflow-flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 28px 24px; margin: 0; padding: 0; list-style: none; }
.workflow-step { position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 0; min-height: 106px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background-color: var(--wash); transition: background-color .6s ease, border-color .6s ease; }
.workflow-step strong { line-height: 1.25; }
.workflow-step small { margin-top: 3px; color: var(--muted); }
.workflow-step span { margin-top: 8px; color: var(--muted); font-size: .88rem; line-height: 1.35; transition: color .6s ease; }
.workflow-step::after { position: absolute; z-index: 1; right: -21px; top: 50%; transform: translateY(-50%); color: var(--accent); font-size: 1.25rem; font-weight: 700; content: "→"; }
.workflow-step:nth-child(4)::after { right: 50%; top: auto; bottom: -30px; transform: translateX(50%); content: "↓"; }
.workflow-step:nth-child(n + 5)::after { right: auto; left: -21px; content: "←"; }
.workflow-step:last-child::after { content: none; }
.workflow-step:nth-child(5) { grid-area: 2 / 4; }
.workflow-step:nth-child(6) { grid-area: 2 / 3; }
.workflow-step:nth-child(7) { grid-area: 2 / 2; }
.workflow-step:nth-child(8) { grid-area: 2 / 1; }
/* The gradient starts and ends on the same colour and the sweep moves it by exactly
   one tile (200% of a 200%-wide image), so each loop joins the next without a jump. */
.workflow-step.active { border-color: #e3c45c; background-color: #fff9e3; background-image: linear-gradient(90deg, rgb(252 230 150 / 0) 20%, #fce696 50%, rgb(252 230 150 / 0) 80%); background-size: 200% 100%; animation: workflow-sweep 2.8s linear infinite; }
.workflow-step.active span { color: #7a5c00; font-weight: 650; }
.workflow-step.complete { border-color: #8bcba7; background-color: rgb(54 176 106 / 17%); }
.workflow-step.complete span { color: var(--accent-dark); }
.workflow-step.failed { border-color: #cf8c82; background-color: #fff1ef; }
.workflow-step.failed span { color: #9b3326; }
@keyframes workflow-sweep { from { background-position: 0 0; } to { background-position: -200% 0; } }
.researcher-header { display: flex; align-items: flex-start; gap: 14px; }
.researcher-header .eyebrow { margin-top: 0; }
.qr-menu { position: relative; z-index: 2; flex: 0 0 auto; }
button.qr-trigger { display: grid; place-items: center; width: 36px; min-height: 36px; padding: 0; }
.qr-panel { display: none; position: absolute; top: 100%; left: 0; width: min(92vw, 1000px); padding-top: 8px; }
.qr-menu.open .qr-panel { display: block; }
.qr-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 48px; padding: 32px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 8px 28px rgb(23 34 29 / 16%); }
.qr-link { display: grid; justify-items: center; gap: 4px; padding: 5px; border-radius: 8px; color: var(--ink); text-decoration: none; }
.qr-link:hover, .qr-link:focus-visible { background: var(--wash); }
.qr-link svg { display: block; width: min(100%, 260px); height: auto; aspect-ratio: 1; background: #fff; shape-rendering: crispEdges; }
.researcher-header h1 span { color: var(--accent); }
.join-code-badge { display: flex; flex-direction: column; align-items: flex-end; }
.join-code-badge .eyebrow { margin: 0; }
.join-code-badge strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; letter-spacing: .12em; color: var(--accent); }
.unlock-note { margin: 0 0 20px; color: var(--muted); font-size: 1.05rem; }
.unlock-form { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }
.unlock-code { width: 7.5ch; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .2em; text-align: center; }
.unlock-code:focus { outline: 3px solid rgb(23 107 75 / 16%); border-color: var(--accent); }
.experiment-timer { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; }
.experiment-timer .eyebrow { margin: 0; }
.experiment-timer strong { font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.seat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.seat { padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.seat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.seat h3 { margin: 0; }
.seat-status { padding: 3px 10px; border-radius: 999px; background: var(--wash); color: var(--muted); font-size: .78rem; font-weight: 700; white-space: nowrap; }
.seat-status.open { background: #e3f2ea; color: var(--accent-dark); }
.seat-status.submitted { background: var(--accent); color: #fff; }
.seat-bar { height: 8px; border-radius: 999px; background: #dde7e1; overflow: hidden; }
.seat-fill { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #176b4b, #25a36a); transition: width .6s cubic-bezier(.22, 1, .36, 1); }
.seat p { margin: 6px 0 0; color: var(--muted); font-size: .9rem; }
.seat .seat-count { margin-top: 8px; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.seat .seat-count:empty { display: none; }
@media (max-width: 680px) {
  .shell { padding-left: 14px; padding-right: 14px; }
  .card { border-radius: 15px; padding: 20px 16px; }
  /* Phones: one vertical list, so a 7-point scale is never split across rows. */
  .scale { grid-template-columns: 1fr; }
  .scale:not(.wide) .choice { display: flex; justify-content: flex-start; gap: 12px; min-height: 44px; padding: 8px 14px; text-align: left; }
  .scale:not(.wide) .scale-label { min-height: 0; font-size: .95rem; }
  .scale.wide { grid-template-columns: repeat(4, 1fr); }
  .seat-grid { grid-template-columns: 1fr; }
  .workflow-flow { grid-template-columns: 1fr; gap: 22px; }
  .workflow-step { min-height: 76px; }
  .workflow-step:nth-child(n) { grid-area: auto / 1; }
  .workflow-step:nth-child(n)::after { right: 50%; left: auto; top: auto; bottom: -26px; transform: translateX(50%); content: "↓"; }
  .workflow-step:last-child::after { content: none; }
  .actions { flex-wrap: wrap; }
  .actions button { flex: 1 1 130px; }
}
@media (prefers-reduced-motion: reduce) {
  .workflow-step.active { animation: none; background-image: none; background-color: #fdeeb5; }
  .workflow-step, .workflow-step span, .seat-fill { transition: none; }
}

.qr-panel { max-height: 85vh; overflow: auto; }

.workflow-step pre { max-height: 8rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .75rem; }
.workflow-step details { margin-top: 10px; font-size: .8rem; }
.workflow-step summary { cursor: pointer; }
.workflow-step button { margin-top: 12px; padding: 8px; font-size: .82rem; }
#interview-feedback { font-size: .8rem; line-height: 1.4; }
.failsafe-controls { display: flex; align-items: center; gap: 8px; margin-right: auto; }
.failsafe-controls select { min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font-weight: 650; }
.failsafe-controls button { min-height: 40px; padding: 6px 14px; font-size: .9rem; }
