/* ============================================================
   SapienStudyRuntime — shared.css
   Unified stylesheet for all neuropsychology task apps.
   Generated: 2026-07-02
   Palette: charcoal / warm-dark / green / gold / red — NO BLUE.
   ============================================================ */

/* ── Reset ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Design tokens ── */
:root {
  --bg:            #0a0a0a;
  --surface:       #141414;
  --surface-2:     #233526;
  --border:        #272727;
  --border-bright: #3a3a3a;
  --text:          #e8e8e8;
  --muted:         #666;
  --dimmed:        #3d3d3d;
  --text-dim:      #a59e8b;
  --label:         #80766b;

  /* semantic colours — no blue */
  --red:    #e05252;
  --green:  #5ec97a;
  --yellow: #d4aa3f;
  --orange: #d97b3a;
  --purple: #9b7fe8;
  --pink:   #d965a0;
  --accent: #f6c13b;   /* warm gold — default accent, override per-task if needed */

  /* typography */
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'IBM Plex Sans', sans-serif;

  /* layout */
  --radius:     6px;
  --transition: 0.22s ease;
}

/* ── Base ── */
html, body {
  width: 100%;
  min-width: 0;
  min-height: 100%;
  height: auto;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 300;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

a,
a:visited,
a:hover,
a:active {
  text-decoration: none !important;
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ── App shell ── */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: auto;
  padding: clamp(1rem, 3vh, 2rem) clamp(0.75rem, 3vw, 1.5rem);
  margin: auto;
}

/* ── Page ── */
.page {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  width: min(100%, 620px);
  max-width: 500px;
  min-width: 0;
  max-height: calc(100dvh - clamp(2rem, 6vh, 4rem));
  height: min(570px, calc(100dvh - clamp(2rem, 6vh, 4rem)));
  margin-block: auto;
  justify-content: flex-start;
  gap: 0.15rem;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  animation: fadein 0.4s ease;
}

.page > * {
  min-width: 0;
  max-width: 100%;
  margin-left: 0;
}

/* size variants used by individual tasks */
.page--wide  { width: 550px; max-width: 90vw; min-height: 500px; height: 500px; justify-content: space-evenly; margin: auto; }
.page--wider { width: 650px; max-width: calc(95vw - 2rem); }
.page--tall  { height: 650px; max-height: 80dvh; }

.page.active { display: flex; flex-direction: column; }
.page.active > .btn,
.page.active > .btn-primary,
.page.active > .btn-row:last-child,
.page.active > .mic-actions:last-child { margin-top: auto !important; }

[id^="pg-results"] {
  width: min(100%, 720px);
  height: auto;
  min-height: 0;
  max-width: 100%;
  max-height: min(calc(100dvh - clamp(2rem, 6vh, 4rem)), 720px);
  margin: auto;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
  align-self: center;
}

#pg-task {
  justify-content: space-between;
  align-items: center;
}

.stroop-task-page {
  display: none;
  grid-template-rows: auto auto minmax(170px, 1fr) auto minmax(18px, auto);
  align-items: center;
  gap: 0.8rem;
}
.stroop-task-page.active { display: grid; }
.stroop-task-page .stats-row,
.stroop-task-page .progress-wrap,
.stroop-task-page .mic-bar { margin-bottom: 0; }
.stroop-stimulus {
  width: 100%;
  min-height: 170px;
  padding: 1rem;
  display: grid;
  grid-template-rows: minmax(90px, 1fr) 28px;
  place-items: center;
}
.stroop-stimulus #stim-hint { margin-top: 0; align-self: end; }
.stroop-results-page { width: min(92vw, 660px); max-width: 660px; padding: 0.25rem; }
.stroop-results-page .result-grid,
.reading-results-page .result-grid,
#pg-results-1 .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

/* ── Typography ── */
h2 {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 1rem;
  line-height: 1.3;
  color: var(--text);
}

h3 { font-weight: 300; }

p {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.75;
  color: #bbb;
  margin-bottom: 0.85rem;
}

ul { list-style: none; margin-bottom: 1rem; }
ul li {
  font-family: var(--font-sans);
  font-size: 14px;
  color: #bbb;
  padding: 5px 0 5px 18px;
  position: relative;
  line-height: 1.6;
}
ul li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--dimmed);
}

ol.instructions {
  margin: 0 0 1rem 1.35rem;
  color: #bbb;
}
ol.instructions li {
  padding: 5px 0 5px 5px;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
}
ol.instructions li::marker { color: var(--text-dim); font-family: var(--font-mono); }

body.stop-signal-study.study-task-active,
body.stop-signal-study.study-task-active * { cursor: none !important; }

.task-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

.step-num {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.step-demo {
  font-family: var(--font-mono);
  font-size: 48px;
  font-weight: 600;
  margin: 1.2rem 0;
  letter-spacing: 0.1em;
}

/* ── Buttons ── */
.btn, select {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.05em;
  padding: 8px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border-bright);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 0.1s;
  margin-top: 1.5rem;
  max-width:155px;
}

select { border: 2px solid var(--border-bright); font-weight: 300; }

.btn:hover        { background: var(--surface); border-color: #555; }
.btn:active       { transform: scale(0.97); }
.btn:disabled     { opacity: 0.35; cursor: not-allowed; }
.btn:disabled:hover { background: transparent; border-color: var(--border-bright); }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
  margin-bottom: 0;
}
.btn-primary:hover {
  background: #000 !important;
  border-color: #000 !important;
  color: #fff !important;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  width: 100%;
  justify-content: space-evenly;
  align-items: center;
}

.page.active > .btn,
.page.active > .btn-primary { align-self: center; }

.restart-btn {
  font-size: 11px;
  width: auto;
  padding: 0 10px;
  letter-spacing: 0.05em;
}

.back-btn {
  position: absolute;
  top: 48px;
  left: 5vw;
  margin-top: 0;
}

/* ── Navigation arrows ── */
.nav-arrows { display: flex; gap: 8px; }

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-family: var(--font-mono);
  transition: border-color var(--transition), background var(--transition);
}
.nav-btn:hover   { border-color: var(--border-bright); background: var(--surface); }

.standalone-study-nav {
  position: fixed;
  top: 1rem;
  left: 1rem;
  right: 1rem;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  pointer-events: none;
}
.standalone-study-nav__control {
  pointer-events: auto;
  min-width: 68px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(10, 10, 10, 0.92);
  color: var(--text-dim);
  font: 400 12px/1.2 var(--font-mono);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}
.standalone-study-nav__control:hover { color: var(--text); border-color: var(--border-bright); }
.standalone-study-nav__control[hidden] { visibility: hidden; }
.nav-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.nav-btn.hidden  { visibility: hidden; }

/* ── Progress bar ── */
.progress-wrap {
  width: 100%;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1.2rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: width 0.35s ease;
}

/* ── Stimulus area ── */
#stim-area {
  width: 100%;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1.2rem;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition);
}

#stim-area.armed    { border-color: var(--border-bright); }
#stim-area.stopping { background: #000; border-color: var(--red); }

/* word display (used by multiple tasks) */
#stim-word {
  font-family: var(--font-mono);
  font-size: 64px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1;
  transition: opacity 0.1s, transform 0.12s;
  user-select: none;
}
#stim-word.flash { opacity: 0.4; transform: scale(1.06); }

#stim-hint {
  position:absolute;
  bottom:10px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmed);
  margin-top: 14px;
  font-family: var(--font-mono);
  text-align: center;
}

/* typing task excerpt */
#exert {
  font-size: 18px;
  line-height: 1.6;
  word-break: break-word;
  max-height: 30vh;
  overflow: hidden;
}
#typed  { color: var(--green); }
#toType { color: var(--text-dim); }

/* ── Feedback line ── */
#feedback-line {
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
  text-align: center;
  width: 100%;
  transition: color 0.2s;
  font-family: var(--font-mono);
  margin-top: 0.5rem;
}
#feedback-line.ok  { color: var(--green); }
#feedback-line.bad { color: var(--red); }

/* ── Stats row ── */
.stats-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 1.2rem;
}
.stat {
  flex: 1;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.stat-lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat-val {
  display: block;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

/* ── Result grid ── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin: 1.2rem 0;
}
.result-card {
  min-width: 0;
  padding: 11px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.result-card .rc-lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.result-card .rc-val {
  display: block;
  font-size: 21px;
  font-weight: 500;
  color: var(--text);
  overflow-wrap: anywhere;
}

.study-account-save {
  width: 100%;
  margin: 1rem 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(20, 20, 20, 0.94);
}
.study-account-save strong {
  display: block;
  color: var(--text);
  font: 500 13px/1.4 var(--font-mono);
}
.study-account-save__copy,
.study-account-save__signin {
  margin: 0.45rem 0 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.5;
}
.study-account-save__choice {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-top: 0.8rem;
  color: var(--text);
  font: 400 12px/1.4 var(--font-sans);
}
.study-account-save__choice input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
}
.study-account-save__fields {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}
.study-account-save__fields[hidden] {
  display: none;
}
.study-account-save__row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}
.study-account-save input:not([type="checkbox"]),
.study-account-save select {
  width: 100%;
  max-width: none;
  min-height: 40px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: 400 13px/1.2 var(--font-sans);
  letter-spacing: 0;
}
.study-account-save .btn {
  width: 100%;
  max-width: none;
  margin-top: 0;
}
.study-account-save__signin a {
  color: var(--text);
}
.study-account-save__msg {
  min-height: 18px;
  color: var(--yellow);
  font: 400 12px/1.4 var(--font-sans);
}
.study-account-save__verify {
  margin-top: 0.8rem;
}

/* ── Settings ── */
.settings-row {
  display: flex;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.setting-control {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}
.setting-control label { font-size: 14px; color: var(--text); }
.setting-control select { margin: 0; width: min(210px, 55%); }
.setting-default { width: 100%; color: var(--yellow); font-size: 12px; margin-top: 0.55rem; }
.inline-status { margin-top: 1rem; min-height: 18px; font-size: 12px; color: var(--muted); }

.attempts-info {
  width: 100%;
  margin-top: 1.5rem;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  text-align: center;
}
.attempts-info.locked {
  color: var(--red);
  border-color: #5a3030;
  background: #1a0d0d;
}

/* ── Warnings ── */
.warn {
  border: 1px solid #5a3030;
  background: #1a0d0d;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: #e08080;
  margin-top: 1rem;
}

.warn-yellow {
  border: 1px solid #5a5330;
  color: var(--yellow);
  background: #1a180d;
  margin-top: 1rem;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 15px;
}
.warn-yellow.tiny {
  font-size: 12px;
  font-weight: 200;
  padding: 6px 10px;
}

.caution {
  border: 1px solid #5a3030;
  background: #1a0d0d;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--yellow);
  margin-top: 1rem;
}

/* ── Trial log ── */
.trial-log {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 0.5rem;
  background: var(--surface);
}

/* head variant used by reaction/SST/typing tasks */
.trial-log-head {
  display: grid;
  grid-template-columns: 0.6fr 1fr 1fr 1.2fr;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 9px 14px;
  gap: 8px;
}
.trial-log-head span {
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label);
}

/* header variant used by word/memory tasks */
.trial-log-header {
  display: grid;
  grid-template-columns: 2fr 2fr 2fr 1.2fr 1.5fr;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 7px 12px;
  gap: 8px;
}
.trial-log-header span {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.trial-log-body {
  max-height: 220px;
  overflow-y: auto;
}

.trial-row {
  display: grid;
  grid-template-columns: 0.6fr 1fr 1fr 1.2fr;
  padding: 7px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
}
.trial-row:last-child { border-bottom: none; }
.trial-row span {
  font-family: var(--font-mono);
  color: #aaa;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  width: fit-content;
}
.badge.ok       { background: #0e2a15; color: var(--green); }
.badge.bad      { background: #2a0e0e; color: var(--red); }
.badge.type-con { background: #1a150a; color: var(--orange); }   /* was blue — replaced */
.badge.type-inc { background: #2a1a10; color: #c4895a; }

/* ── Past attempts ── */
#past-attempts { width: 100%; }

.past-list {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.past-row {
  display: grid;
  grid-template-columns: 0.5fr 1fr 1fr 0.7fr;
  padding: 8px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
}
.past-row:last-child { border-bottom: none; }
.past-row span {
  font-family: var(--font-mono);
  color: #aaa;
}

/* ── Scrollbars ── */
.trial-log-body::-webkit-scrollbar { width: 4px; }
.trial-log-body::-webkit-scrollbar-track { background: var(--surface); }
.trial-log-body::-webkit-scrollbar-thumb { background: var(--border-bright); border-radius: 4px; }

/* ── Check / radio cards ── */
.check-group {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 560px;
  margin: 24px 0;
}

/* horizontal variant for 2-option toggles */
.check-group--row {
  flex-direction: row;
  justify-content: space-between;
}

.check-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 22px;
  flex: 1;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
  user-select: none;
}
.check-item:hover  { background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.16); }
.check-item:active { transform: scale(0.995); }

.check-item input[type="radio"],
.check-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
input[type="radio"] { display: none; }

/* circle indicator (default — used for radio) */
.check-box {
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255,255,255,0.25);
  border-radius: 50%;
  background: transparent;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}
.check-box::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #111;
  transform: translate(-50%,-50%) scale(0);
  transition: transform 0.15s ease;
}

.check-item input:checked ~ .check-box {
  background: var(--green);
  border-color: var(--green);
}
.check-item input:checked ~ .check-box::after {
  transform: translate(-50%,-50%) scale(1);
}
.check-item:has(input:checked) {
  background: rgba(94,201,122,0.08);
  border-color: rgba(94,201,122,0.35);
}
.check-item input:focus-visible ~ .check-box {
  outline: 2px solid var(--green);
  outline-offset: 3px;
}

.check-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 87%;
}
.check-title {
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
}
.check-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.45;
}

/* ── Mic status bar ── */
.mic-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  width: 100%;
  margin-bottom: 1.5rem;
}
.mic-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dimmed);
  flex-shrink: 0;
  transition: background 0.3s;
}
.mic-dot.listening { background: var(--red); animation: blink 1s infinite; }
.mic-dot.ready     { background: var(--green); }
.mic-label {
  font-size: 13px;
  color: var(--muted);
  font-family: var(--font-mono);
}
.mic-heard {
  margin-left: auto;
  font-size: 13px;
  color: var(--dimmed);
  font-family: var(--font-mono);
  max-width: 200px;
  min-width:150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Response input bar ── */
.input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  width: 100%;
  margin-bottom: 1.5rem;
}
#response-field {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 18px;
  letter-spacing: 0.15em;
  text-align: center;
}
#response-field::placeholder {
  color: var(--dimmed);
  letter-spacing: normal;
  font-size: 13px;
}

/* ── Probe / reaction stimulus ── */
.probe {
  font-size: 120px;
  font-weight: 500;
  line-height: 1;
  color: var(--accent);
  user-select: none;
  animation: probe-in 0.06s ease;
}
@keyframes probe-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.stim-hint {
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
}

/* ── Sound button ── */
.sound-btn {
  display: inline-grid;
  place-items: center;
  width: clamp(60px, 14vw, 72px);
  min-width: 60px;
  height: clamp(60px, 14vw, 72px);
  min-height: 60px;
  aspect-ratio: 1;
  margin-inline: auto;
  padding: 0;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 70%, var(--border-bright));
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.11), transparent 42%),
    var(--surface);
  color: var(--accent);
  box-shadow:
    0 8px 22px rgba(0, 0, 0, 0.28),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  font-size: clamp(28px, 7vw, 36px);
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition), transform 0.1s;
}
.sound-btn:hover {
  border-color: var(--accent);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.15), transparent 42%),
    var(--surface-2);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.34),
    0 0 0 5px color-mix(in srgb, var(--accent) 12%, transparent);
  transform: translateY(-2px);
}
.sound-btn:active  { transform: scale(0.94); }
.sound-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }
.sound-btn.pulsing { animation: pulse-ring 0.9s ease-in-out infinite; }

/* ── Stop-Signal Task ── */
.fixation { font-size: 64px; color: var(--dimmed); user-select: none; }

.arrow {
  font-size: 100px;
  line-height: 1;
  color: var(--text);
  user-select: none;
  animation: probe-in 0.06s ease;
}

.stop-cue {
  font-size: 96px;
  line-height: 1;
  color: var(--red);
  user-select: none;
  animation: probe-in 0.06s ease;
}

.key-legend {
  display: flex;
  gap: 28px;
  justify-content: center;
  align-items: center;
  width: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--muted);
}
.key-legend b { color: var(--text); font-weight: 500; }
.key-cap {
  display: inline-block;
  min-width: 26px;
  padding: 2px 8px;
  border: 1px solid var(--border-bright);
  border-radius: 4px;
  color: var(--accent);
  font-weight: 500;
  text-align: center;
}

/* ── Sound Recall ── */
.phase {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  width: 100%;
}
.phase.active { display: flex; }

.phase-title {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
  text-align: center;
}

.countdown {
  font-size: 72px;
  font-weight: 300;
  color: var(--accent);
  font-family: var(--font-mono);
  line-height: 1;
}

/* frequency slider — gold thumb, no blue */
input[type="range"].freq {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--border-bright);
  outline: none;
  accent-color: var(--green);
  cursor: pointer;
  margin: 0.4rem 0;
}
input[type="range"].freq::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
  transition: transform 0.1s;
}
input[type="range"].freq::-webkit-slider-thumb:active { transform: scale(1.15); }
input[type="range"].freq::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  cursor: pointer;
}
input[type="range"].freq::-moz-range-track {
  height: 4px;
  border-radius: 4px;
  background: var(--border-bright);
}

.recall-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
}

/* ── Chart wrapper ── */
.chart-wrap {
  width: 100%;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}
.chart-wrap canvas { max-height: 220px; }

.chart-legend {
  display: flex;
  gap: 18px;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}
.chart-legend .swatch {
  display: inline-block;
  width: 14px;
  height: 3px;
  vertical-align: middle;
  margin-right: 5px;
}

/* ── Canvas (EEG / pitch plots) ── */
canvas {
  image-rendering: pixelated;
  border: 2px solid var(--accent);
  width: 250px;
  height: 150px;
  max-width: 100%;
  margin: auto;
}

strong.plot-label {
  margin: auto;
  margin-block-start: 2rem;
  text-align: center;
}

.canvas-cont {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  height: 100%;
  margin: auto;
}

/* ── Config preset buttons ── */
.config-options { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }

.preset-btn {
  padding: 9px 16px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition), border-color var(--transition);
}
.preset-btn.active { background: var(--green); color: #111; border-color: var(--green); }

.custom-row { display: flex; align-items: center; gap: 10px; margin: 12px 0; }
.custom-row input { padding: 8px; width: 100px; }

/* ── Checkbox (non-radio) ── */
input[type="checkbox"] {
  width: 25px;
  height: 25px;
  accent-color: var(--green);
  margin: auto;
  margin-right: 0;
}

/* ── Touch-only elements ── */
.touch-only { display: none !important; }
body.has-touched .touch-only { display: inline-flex !important; }
body.has-touched #stim-hint { display: none; }
.touch-actions { display: flex; gap: 0.75rem; width: 100%; justify-content: center; }
.prereq-confirm { display: flex; align-items: center; gap: 0.75rem; margin-top: 0.75rem; color: var(--muted); }
.prereq-confirm input { margin: 0; flex: 0 0 auto; }
.study-select { width: 100%; margin: 0.5rem 0; padding: 0.7rem; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.task-surface-unboxed { border: 0 !important; background: transparent !important; box-shadow: none !important; }

.reading-task-page { justify-content: space-between; align-items: center; }
.reading-passage {
  min-height: 210px;
  padding: 1.25rem 0.5rem !important;
  display: flex;
  align-items: center;
}
.reading-passage #exert {
  max-height: 40dvh;
  overflow-y: auto;
  color: var(--text-dim);
  font-size: 17px;
  line-height: 1.8;
  text-align: left;
}
.read-correct { color: var(--green); }
.read-missed { color: var(--red); text-decoration: underline; text-decoration-thickness: 1px; }
.read-current { color: var(--text); border-bottom: 1px solid var(--yellow); }
.reading-results-page { width: min(92vw, 650px); max-width: 650px; }
.reading-result-copy {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
  margin: 0.35rem 0 0.75rem;
}
.reading-result-copy > div {
  min-width: 0;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.reading-result-copy .section-label { display: block; margin-bottom: 0.45rem; }
.reading-result-copy p { max-height: 120px; overflow-y: auto; margin: 0; font-size: 12px; line-height: 1.55; }
.result-context { text-align: center; width: 100%; font-size: 12px; color: var(--muted); }

/* ── Animations ── */
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 0  rgba(246, 193, 59, 0.0); }
  50%       { box-shadow: 0 0 0 10px rgba(246, 193, 59, 0.12); }
}

/* ── Responsive ── */
@media (max-width: 768px) {
  #app {
    justify-content: center;
    min-height: 100dvh;
    height: 100dvh;
    overflow: hidden;
    padding: 1.25rem;
  }
  body.standalone-study #app { padding-top: 4.25rem; }

  #app > .page {
    width: min(100%, 560px);
    max-width: 100%;
    height: auto;
    min-height: auto;
    max-height: calc(100dvh - 2.5rem);
    margin-block: auto;
  }

  body.standalone-study #app > .page {
    max-height: calc(100dvh - 5.5rem);
  }

  .page-header { gap: 0.75rem; margin-bottom: 1.25rem; }

  #stim-area { min-height: 140px; padding: 1rem; }

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

  .stats-row { flex-direction: row; height: auto; }

  .canvas-cont { max-height: 50%; }
  .canvas-cont > canvas { height: 70%; width: 100%; }

  strong.plot-label { margin: 0.5rem; }
}

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

@media (max-width: 480px) {
  #app { padding: 1rem; }

  body.standalone-study #app {
    padding: 4rem 0.75rem 0.75rem;
  }

  #app > .page,
  :is(.study-standalone, .mosaic-standalone) #app > .page {
    width: 100%;
    max-width: 100%;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-arrows { width: 100%; justify-content: space-between; }
  h2 { font-size: 20px; }
  p, ul li { font-size: 14px; }
  .btn, .btn-primary {
    width: 100%;
    margin:auto;
    max-width:165px;
    text-align: center;
  }

  #stim-word { font-size: 42px; }
  .stat-val  { font-size: 16px; }

  .result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .touch-actions .btn { width: auto; flex: 1 1 0; max-width: none; }
  .reading-result-copy { grid-template-columns: 1fr; }
  .study-account-save__row { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .page,
  .sound-btn,
  .sound-btn.pulsing {
    animation: none;
    transition: none;
  }
}

button {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
