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

:root {
  --primary: #4338ca;
  --primary-light: #6366f1;
  --primary-dark: #3730a3;
  --accent: #f59e0b;
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --danger: #ef4444;
  --success: #10b981;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

#app { min-height: 100vh; }

/* Screens */
.screen { display: none; min-height: 100vh; align-items: center; justify-content: center; padding: 2rem; }
.screen.active { display: flex; }

/* Loading */
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem;
  max-width: 640px;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Logo */
.logo { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 2rem; }
.logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.logo span { font-weight: 600; font-size: 1.1rem; color: var(--text); }

/* Typography */
h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 0.75rem; color: var(--text); }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.5rem; }
h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; }

.meta-info {
  display: flex; gap: 1rem; flex-wrap: wrap;
  margin: 1.5rem 0; padding: 1rem;
  background: #f1f5f9; border-radius: 8px;
  font-size: 0.875rem; color: var(--text-muted);
}
.meta-info span { display: flex; align-items: center; gap: 0.25rem; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: var(--font); font-size: 0.9375rem; font-weight: 500;
  border: none; border-radius: 10px;
  cursor: pointer; transition: all 0.15s;
  min-width: 160px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.8125rem; min-width: auto; }

/* Input */
.input {
  width: 100%; padding: 0.75rem 1rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font); font-size: 0.9375rem;
  transition: border-color 0.15s;
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(67,56,202,0.1); }

/* Consent */
.consent-body {
  max-height: 400px; overflow-y: auto;
  padding: 1.5rem; margin: 1rem 0;
  background: #f8fafc; border-radius: 8px; border: 1px solid var(--border);
  font-size: 0.9375rem; line-height: 1.8; white-space: pre-wrap;
}
.consent-body strong { font-weight: 600; }

.biometric-options { margin: 1.5rem 0; }
.biometric-option {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; margin-bottom: 0.5rem;
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.biometric-option:hover { border-color: var(--primary-light); }
.biometric-option.required { background: #f0f0ff; }
.biometric-option input[type="checkbox"] {
  width: 18px; height: 18px; accent-color: var(--primary);
}
.biometric-option label { flex: 1; font-size: 0.9375rem; cursor: pointer; }
.biometric-option .required-badge {
  font-size: 0.75rem; color: var(--primary); font-weight: 500;
  background: rgba(67,56,202,0.1); padding: 0.125rem 0.5rem; border-radius: 4px;
}

.consent-actions { display: flex; gap: 1rem; margin-top: 1.5rem; }
.consent-actions .btn { flex: 1; }

/* Calibration */
.calibration-container { max-width: 720px; width: 100%; text-align: center; }
.webcam-box {
  width: 480px; height: 360px; max-width: 100%;
  margin: 1.5rem auto; position: relative;
  background: #000; border-radius: 12px; overflow: hidden;
}
.webcam-box video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.face-indicator {
  position: absolute; bottom: 1rem; left: 50%; transform: translateX(-50%);
  background: var(--success); color: white; padding: 0.25rem 1rem;
  border-radius: 20px; font-size: 0.8125rem; font-weight: 500;
}

.cal-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 2rem; max-width: 600px; margin: 2rem auto; padding: 2rem;
}
.cal-point {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--border); cursor: pointer; margin: auto;
  transition: all 0.2s;
}
.cal-point.active { background: var(--primary); transform: scale(1.5); }
.cal-point.done { background: var(--success); }

.mic-section { margin: 1.5rem 0; }
.mic-level-bar {
  height: 8px; background: var(--border); border-radius: 4px;
  overflow: hidden; margin: 0.75rem 0;
}
.mic-level-bar > div { height: 100%; background: var(--success); border-radius: 4px; transition: width 0.1s; width: 0%; }

/* Study Screen */
.progress-bar { position: fixed; top: 0; left: 0; right: 0; height: 4px; background: var(--border); z-index: 100; }
.progress-fill { height: 100%; background: var(--primary); transition: width 0.3s; }

.block-container {
  max-width: 800px; width: 100%; margin: 2rem auto; padding: 2rem;
}

.withdraw-floating {
  position: fixed; bottom: 1rem; right: 1rem; z-index: 50;
  opacity: 0.6; transition: opacity 0.2s;
}
.withdraw-floating:hover { opacity: 1; }

/* Block Types */
.stimulus-container { text-align: center; }
.stimulus-container img { max-width: 100%; max-height: 70vh; border-radius: 8px; }
.stimulus-container video { max-width: 100%; max-height: 70vh; border-radius: 8px; }

.survey-container { max-width: 600px; margin: 0 auto; }
.survey-question { margin-bottom: 2rem; }
.survey-question p { font-size: 1rem; font-weight: 500; margin-bottom: 1rem; }

.likert-scale {
  display: flex; justify-content: space-between; gap: 0.5rem;
}
.likert-option {
  flex: 1; text-align: center; padding: 0.75rem 0.5rem;
  border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; font-size: 0.875rem; transition: all 0.15s;
}
.likert-option:hover { border-color: var(--primary-light); }
.likert-option.selected { background: var(--primary); color: white; border-color: var(--primary); }
.likert-anchors { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); margin-top: 0.5rem; }

.mc-options { display: flex; flex-direction: column; gap: 0.5rem; }
.mc-option {
  padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: 8px;
  cursor: pointer; transition: all 0.15s; font-size: 0.9375rem;
}
.mc-option:hover { border-color: var(--primary-light); background: #fafafe; }
.mc-option.selected { background: var(--primary); color: white; border-color: var(--primary); }

.slider-container { margin: 1rem 0; }
.slider-container input[type="range"] { width: 100%; accent-color: var(--primary); }
.slider-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: var(--text-muted); }
.slider-value { text-align: center; font-weight: 600; font-family: var(--mono); margin-top: 0.5rem; }

textarea.survey-textarea {
  width: 100%; min-height: 120px; padding: 1rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font); font-size: 0.9375rem; resize: vertical;
}
textarea.survey-textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(67,56,202,0.1); }

/* Reaction Time */
.rt-display {
  display: flex; align-items: center; justify-content: center;
  min-height: 60vh; font-size: 4rem; font-weight: 700;
  user-select: none;
}
.rt-fixation { color: var(--text-muted); }
.rt-feedback { font-size: 1.5rem; margin-top: 1rem; }
.rt-feedback.correct { color: var(--success); }
.rt-feedback.incorrect { color: var(--danger); }

/* Voice */
.voice-container { text-align: center; }
.voice-timer { font-family: var(--mono); font-size: 2rem; font-weight: 600; margin: 1rem 0; }
.voice-waveform { height: 80px; background: #f1f5f9; border-radius: 8px; margin: 1rem 0; }

/* Instructions */
.instructions-container {
  max-width: 600px; margin: 0 auto;
  font-size: 1rem; line-height: 1.8;
}
.instructions-container strong { font-weight: 600; }

/* Thank you */
.thankyou-card { text-align: center; }
.checkmark {
  width: 64px; height: 64px; margin: 0 auto 1.5rem;
  background: var(--success); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.mono { font-family: var(--mono); font-size: 0.875rem; color: var(--text-muted); }
.small-text { font-size: 0.875rem; color: var(--text-muted); margin-top: 1rem; }

/* Error */
.error-container { text-align: center; }
.error-icon {
  width: 64px; height: 64px; margin: 0 auto 1.5rem;
  background: var(--danger); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 700;
}

/* Utilities */
.hidden { display: none !important; }

/* Fullscreen overlay */
#fullscreen-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.9);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; color: white; text-align: center;
}
#fullscreen-overlay h2 { color: white; margin-bottom: 1rem; }
