:root {
  --bg: #2b2b2e;
  --panel: #36363a;
  --text: #e8e8ea;
  --muted: #a9a9b0;
  --accent: #7fb2ff;
  --warn: #ffcf70;
  --line: #4a4a50;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { overflow-x: hidden; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
body.running { background: #808080; overflow: hidden; cursor: none; }

#app { padding: 32px 16px 64px; }
#stage { position: fixed; inset: 0; display: block; }
#stage[hidden] { display: none; }

.panel { max-width: 760px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 28px 32px; }
h1 { margin-top: 0; font-size: 1.8rem; }
h2 { margin-top: 0; }
h3 { margin-bottom: .4em; }
.lead { font-size: 1.15rem; color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; }
.warn { color: var(--warn); }
a { color: var(--accent); }

button { font: inherit; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); background: #44444a; color: var(--text); cursor: pointer; }
button.primary { background: var(--accent); color: #111; border-color: transparent; font-weight: 600; }
button:disabled { opacity: .45; cursor: not-allowed; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

label { display: block; margin: 10px 0; }
input[type=text], input[type=number], select { font: inherit; padding: 6px 8px; background: #2a2a2d; color: var(--text); border: 1px solid var(--line); border-radius: 6px; margin-left: 6px; }
input[type=text] { width: min(100%, 360px); }
.consent { margin: 20px 0; font-weight: 600; }
details { margin: 16px 0; }
kbd { background: #222; border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; }

/* Questionnaire */
.q fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 18px 0; padding: 12px 16px; }
.q legend { font-weight: 700; padding: 0 6px; }
.radios { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.radios label, .checks label { margin: 3px 0; display: inline-flex; align-items: center; gap: 6px; }
.checks { display: flex; flex-direction: column; }
.diag td, .likert td { padding: 6px 4px; vertical-align: top; border-bottom: 1px solid var(--line); }
.diag td:first-child, .likert td:first-child { width: 42%; }
.likert .radios { flex-direction: column; gap: 0; }
.scale { display: flex; align-items: center; gap: 10px; }
.scale input { flex: 1; }
.scale output { width: 2ch; text-align: right; font-weight: 700; }

/* Calibration */
.card-stage { min-height: 360px; display: flex; align-items: center; justify-content: center; }
.card-shape { background: linear-gradient(135deg, #4d7fd1, #2b4f8f); border-radius: 3.2% / 5%; border: 1px solid #9cc0ff; }
#cardSlider { width: 100%; }
.bs-stage { position: relative; height: 120px; width: 100vw; margin-left: calc(50% - 50vw); background: #fff; margin-top: 16px; margin-bottom: 8px; }
.eye-reminder { font-size: 1.2rem; font-weight: 700; color: var(--warn); margin: 12px 0 0; }
.bs-msg { color: var(--warn); min-height: 1.5em; }
.bs-stage:has(.bs-rest:not([hidden])) { height: auto; min-height: 120px; }
.bs-rest { position: relative; z-index: 2; background: #2a2a2d; color: var(--text); text-align: center; padding: 16px; }
.bs-rest[hidden] { display: none; }
.bs-rest-timer { font: 700 2.6rem ui-monospace, Consolas, monospace; }
.bs-square { position: absolute; top: 45px; width: 30px; height: 30px; background: #000; }
.bs-dot { position: absolute; top: 50px; width: 20px; height: 20px; border-radius: 50%; background: #e00; }

.reassure { background: #2f3b4f; border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 6px; margin: 16px 0; }
.setup li { margin: 6px 0; }
textarea { display: block; width: 100%; margin-top: 6px; font: inherit; padding: 8px; background: #2a2a2d; color: var(--text); border: 1px solid var(--line); border-radius: 6px; }
.screeners { margin: 20px 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 8px; }
.screeners summary { cursor: pointer; font-weight: 600; }
.countdown { text-align: center; margin: 24px 0; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: #2a2a2d; }
.countdown-label { text-transform: uppercase; letter-spacing: .2em; color: var(--accent); font-weight: 700; }
.timer { font: 700 3.2rem ui-monospace, Consolas, monospace; margin-top: 6px; }
.big-steps { font-size: 1.25rem; line-height: 1.9; }

/* Task demo */
.demo canvas { width: 100%; height: auto; border-radius: 6px; }

/* Results */
.bar-row { display: grid; grid-template-columns: 170px 1fr 70px; align-items: center; gap: 10px; margin-top: 10px; }
.bar-track { position: relative; height: 16px; background: #2a2a2d; border-radius: 4px; }
.bar-zero { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 1px; background: var(--muted); }
.bar-fill { position: absolute; top: 0; bottom: 0; background: var(--accent); border-radius: 3px; }
.bar-val { font-variant-numeric: tabular-nums; text-align: right; font-weight: 700; }
.bar-row + .hint { margin-top: 2px; }
.code { font: 700 1.8rem ui-monospace, Consolas, monospace; letter-spacing: .15em; }

@media (max-width: 600px) {
  .panel { padding: 20px 16px; }
  .diag td:first-child, .likert td:first-child { width: auto; }
  .diag tr, .likert tr { display: flex; flex-direction: column; }
}

.pilot-table { width: 100%; border-collapse: collapse; margin: 12px 0; }
.pilot-table th, .pilot-table td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }

.before { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 16px 0; }
.before legend { font-weight: 600; padding: 0 6px; }

/* Follow-up questions that slide open when they apply */
.reveal { max-height: 0; opacity: 0; overflow: hidden; transition: max-height .4s ease, opacity .3s ease; }
.reveal.open { max-height: 1600px; opacity: 1; }
label.reveal { display: block; }

/* Unanswered sliders: faded until moved */
.scale input.untouched { opacity: .45; }
.scale output { min-width: 3ch; }
.scale-zero { padding: 3px 9px; font-size: .85rem; white-space: nowrap; }
