:root {
  --border: #dcdfe4;
  --bg: #f6f7f9;
  --panel-bg: #ffffff;
  --text: #1c2024;
  --muted: #667085;
  --accent: #0b5ed7;
  --accent-contrast: #ffffff;
  --danger: #c0392b;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

#app { height: 100%; }

.screen { height: 100%; }
.hidden { display: none !important; }

/* ---------- Consent screen ---------- */
#consent-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 40px 16px;
}

.consent-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 720px;
  width: 100%;
  padding: 32px 36px;
}

.consent-card h1 {
  margin-top: 0;
  font-size: 1.5rem;
}

.consent-card h2 {
  font-size: 1.05rem;
  margin: 20px 0 8px;
}

.consent-card p, .consent-card li {
  line-height: 1.5;
  color: var(--text);
}

.consent-card ul { padding-left: 20px; }

.field {
  margin-top: 20px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.field input[type="text"],
.field select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 1rem;
  background: #fff;
  font-family: inherit;
}

.field input[readonly],
.field select[disabled] {
  background: #f0f2f5;
  color: var(--muted);
}

.field-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 20px;
}

.consent-check input {
  margin-top: 4px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.consent-check label { line-height: 1.4; }

.primary-btn {
  margin-top: 24px;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  padding: 12px 22px;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.primary-btn:disabled {
  background: #a9c6ec;
  cursor: not-allowed;
}

.error-text {
  color: var(--danger);
  font-size: 0.88rem;
  margin-top: 10px;
  min-height: 1.2em;
}

.resume-banner {
  background: #fff7e6;
  border: 1px solid #f2c14e;
  color: #7a5b00;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 20px;
  font-size: 0.9rem;
}

/* ---------- Study screen ---------- */
#study-screen {
  display: flex;
  flex-direction: column;
}

#progress-header {
  padding: 12px 20px;
  background: var(--panel-bg);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

#progress-label {
  font-weight: 600;
  white-space: nowrap;
}

#progress-track {
  flex: 1;
  height: 8px;
  background: #e7e9ec;
  border-radius: 4px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 0.25s ease;
}

#main-panels {
  flex: 1;
  display: flex;
  min-height: 0;
}

#story-panel {
  flex: 1 1 62%;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--panel-bg);
}

#story-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

#question-panel {
  flex: 1 1 38%;
  max-width: 440px;
  min-width: 320px;
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#question-form {
  padding: 24px 24px 16px;
  flex: 1;
}

.question-block {
  margin-bottom: 26px;
}

.question-block .q-text {
  font-weight: 600;
  margin-bottom: 10px;
  line-height: 1.4;
}

.likert-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.likert-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.likert-option input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.likert-option span {
  font-size: 0.72rem;
  color: var(--muted);
  text-align: center;
}

.likert-endcaps {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 4px;
}

.question-block textarea {
  width: 100%;
  min-height: 70px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.92rem;
  resize: vertical;
}

#question-actions {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

#next-btn {
  width: 100%;
}

#save-status {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 8px;
  min-height: 1.2em;
}

/* ---------- Completion screen ---------- */
#complete-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.complete-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 560px;
  width: 100%;
  padding: 36px;
  text-align: center;
}

.complete-card h1 { margin-top: 0; }

.complete-card a.primary-btn {
  display: inline-block;
  text-decoration: none;
  margin-top: 20px;
}

@media (max-width: 860px) {
  #main-panels { flex-direction: column; }
  #story-panel { flex: 1 1 50%; border-right: none; border-bottom: 1px solid var(--border); }
  #question-panel { flex: 1 1 50%; max-width: none; }
}
