/* Sleep Study web pilot — light theme kept deliberately plain so the stimuli
   (word pairs, object photos) are the only thing that draws the eye. */
:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1b1f24;
  --muted: #5c6672;
  --line: #d9dee5;
  --accent: #1f7a3a;        /* primary (green) button, like the desktop app */
  --accent-ink: #ffffff;
  --accent-hover: #196530;
  --danger: #b00020;
  --ok: #1a6b1a;
  --stim-bg: #f4f4f2;       /* MDT canvas background in the app */
  --focus: #2b6cb0;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 18px; line-height: 1.45;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
#app { max-width: 880px; margin: 0 auto; padding: 24px 16px 48px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 28px 28px 24px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
@media (max-width: 600px) { .card { padding: 20px 16px; } body { font-size: 17px; } }
h1 { font-size: 1.7rem; margin: 0 0 12px; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; margin: 20px 0 8px; }
p { margin: 10px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.center { text-align: center; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
pre.example {
  background: #f1f3f5; border-radius: 8px; padding: 10px 14px; font-size: 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: pre-wrap;
}
ul { padding-left: 22px; } li { margin: 4px 0; }

/* Buttons */
button {
  font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: 12px 22px; min-width: 120px;
  transition: background .12s, transform .05s;
}
button:hover { background: #f1f3f5; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button[disabled] { opacity: .45; cursor: default; }
button[disabled]:hover { background: #fff; }
button.primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
  font-weight: 600; padding: 14px 40px; font-size: 1.1rem;
}
button.primary:hover { background: var(--accent-hover); }
button.primary[disabled]:hover { background: var(--accent); }
button.link { border: 0; background: none; color: var(--focus); text-decoration: underline; min-width: 0; padding: 6px 8px; }
button.link:hover { background: none; }
.btn-row { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.btn-row.wide button { min-width: 150px; padding: 16px 28px; font-size: 1.15rem; }
.actions { margin-top: 24px; text-align: center; }

/* Forms */
form .field { margin: 14px 0; }
label { display: block; font-weight: 600; margin-bottom: 4px; }
label .hint { font-weight: 400; color: var(--muted); font-size: .9rem; }
input[type=text], input[type=number], input[type=time], select, textarea {
  font: inherit; width: 100%; max-width: 420px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.radio-row label { font-weight: 400; display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.scale { display: flex; flex-wrap: wrap; gap: 6px; }
.scale label {
  font-weight: 400; margin: 0; border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; background: #fff;
}
.scale input { margin: 0; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.consent input { margin-top: 6px; width: 20px; height: 20px; }
.error { color: var(--danger); font-weight: 600; }
.notice { background: #fff8e1; border: 1px solid #f3dd8a; border-radius: 8px; padding: 10px 14px; }
.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 2.2rem;
  letter-spacing: .18em; background: #f1f3f5; border-radius: 10px; padding: 14px 20px;
  display: inline-block; margin: 8px 0;
}
.code-link { word-break: break-all; font-size: .95rem; }

/* Task screens */
.task { text-align: center; }
.task .progress { color: var(--muted); font-size: 1rem; min-height: 1.4em; margin-bottom: 8px; }
.task .instruction { font-size: 1.05rem; min-height: 1.5em; margin: 10px 0; }
.wp-display {
  font-size: clamp(2rem, 6vw, 3.2rem); font-weight: 600; letter-spacing: .02em;
  min-height: 1.4em; margin: 10vh 0 16px; word-break: break-word;
}
@media (max-width: 600px) { .wp-display { margin-top: 6vh; } }
.wp-feedback { min-height: 1.6em; font-size: 1.15rem; font-weight: 600; }
.wp-feedback.ok { color: var(--ok); } .wp-feedback.bad { color: var(--danger); }
.wp-entry {
  font-size: 1.5rem; text-align: center; max-width: 360px; padding: 12px 14px;
  text-transform: lowercase;
}
.mdt-frame {
  width: min(78vw, 56vh, 480px); height: min(78vw, 56vh, 480px);
  margin: 0 auto; background: var(--stim-bg); border: 2px solid #888; border-radius: 6px;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.mdt-frame img { max-width: calc(100% - 16px); max-height: calc(100% - 16px); display: block; }
.mdt-feedback { min-height: 1.6em; font-size: 1.1rem; font-weight: 600; margin-top: 8px; }
.mdt-feedback.ok { color: var(--ok); } .mdt-feedback.bad { color: #b04040; }
.loading-bar { height: 10px; background: #e6e9ee; border-radius: 6px; overflow: hidden; max-width: 420px; margin: 12px auto; position: relative; }
.loading-bar > div { height: 100%; width: 0; background: var(--accent); transition: width .15s; }
/* Indeterminate: a sliding block, for waits with no measurable progress (server round trips). */
.loading-bar.indeterminate > div { width: 35%; position: absolute; left: 0; animation: ss-slide 1.3s ease-in-out infinite; transition: none; }
@keyframes ss-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(400%); } }
.save-status { margin-top: 18px; font-size: .9rem; color: var(--muted); display: flex; gap: 10px; align-items: center; justify-content: center; }
.save-status .loading-bar { width: 140px; margin: 0; height: 6px; }
.save-status.ok { color: var(--ok); }

/* Results table on the thank-you page */
table.results { border-collapse: collapse; margin: 12px auto; }
table.results td, table.results th { border: 1px solid var(--line); padding: 6px 12px; text-align: center; }
table.results th { background: #f1f3f5; font-weight: 600; }

/* Effort warning overlay */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 24, 30, .72); z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.warning-card { max-width: 620px; border: 3px solid var(--danger); }
.warning-card h1 { color: var(--danger); font-size: 1.35rem; }

footer { margin-top: 28px; color: var(--muted); font-size: .85rem; text-align: center; }
.sr-only { position: absolute; left: -9999px; }
