/* ========================================
   PsyTest Platform — Modern Design System
   ======================================== */

:root {
  /* Primary palette — deep indigo */
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #6366f1;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --primary-500: #6366f1;

  /* Accent — teal */
  --accent: #0d9488;
  --accent-light: #14b8a6;
  --accent-50: #f0fdfa;

  /* Semantic */
  --success: #10b981;
  --success-bg: #d1fae5;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;

  /* Neutrals */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Surfaces */
  --bg: #f9fafb;
  --bg-elev: #ffffff;
  --bg-input: #ffffff;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  /* Text */
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.07), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 10px 28px rgba(0, 0, 0, 0.12);
  --shadow-xl: 0 20px 48px rgba(0, 0, 0, 0.15);

  /* Radius */
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions */
  --tr: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Material Symbols */
.material-symbols-rounded,
.material-icons-round,
.material-icons {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  vertical-align: middle;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; color: var(--text); line-height: 1.25; }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }

p { color: var(--text); }

a { color: var(--primary); text-decoration: none; transition: color var(--tr); }
a:hover { color: var(--primary-dark); }

/* ========================================
   Loader
   ======================================== */
.app-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 1s linear infinite; display: inline-block; }

/* ========================================
   Buttons
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--tr);
  white-space: nowrap;
  text-decoration: none;
  background: var(--bg-elev);
  color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn .material-symbols-rounded,
.btn .material-icons-round { font-size: 18px; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: var(--shadow); }

.btn-accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-accent:hover { background: #0f766e; }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; }

.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover { background: #dc2626; }

.btn-warning { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #d97706; }

.btn-outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--gray-100); color: var(--text); }

.btn-orange { background: #ea580c; color: #fff; border-color: #ea580c; }
.btn-orange:hover { background: #c2410c; }

.btn-secondary { background: var(--gray-100); color: var(--text); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }

.w-full { width: 100%; }

/* ========================================
   Forms
   ======================================== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color var(--tr), box-shadow var(--tr);
  outline: none;
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.form-input:disabled { background: var(--gray-50); color: var(--text-muted); }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 34px;
}

/* ========================================
   Cards
   ======================================== */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--tr);
}
.card.card-hover:hover { box-shadow: var(--shadow-md); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1rem; font-weight: 600; margin: 0; }

/* ========================================
   Badges & Labels
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-default { background: var(--gray-100); color: var(--gray-700); }
.badge-primary { background: var(--primary-50); color: var(--primary-dark); }
.badge-success { background: var(--success-bg); color: #047857; }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-danger { background: var(--danger-bg); color: #b91c1c; }
.badge-info { background: var(--info-bg); color: #1d4ed8; }

/* ========================================
   Tables
   ======================================== */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
thead tr { background: var(--gray-50); }
thead th {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--tr); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 12px 16px; color: var(--text); vertical-align: middle; }

/* ========================================
   Stat Cards
   ======================================== */
.stat-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
  transition: all var(--tr);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-icon .material-symbols-rounded { font-size: 24px; }
.stat-value { font-size: 1.875rem; font-weight: 700; line-height: 1.1; color: var(--text); }
.stat-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }

.stat-card.color-primary .stat-icon { background: var(--primary-50); color: var(--primary); }
.stat-card.color-primary { border-left: 3px solid var(--primary); }
.stat-card.color-success .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.color-success { border-left: 3px solid var(--success); }
.stat-card.color-warning .stat-icon { background: var(--warning-bg); color: var(--warning); }
.stat-card.color-warning { border-left: 3px solid var(--warning); }
.stat-card.color-danger .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.color-danger { border-left: 3px solid var(--danger); }
.stat-card.color-info .stat-icon { background: var(--info-bg); color: var(--info); }
.stat-card.color-info { border-left: 3px solid var(--info); }
.stat-card.color-accent .stat-icon { background: var(--accent-50); color: var(--accent); }
.stat-card.color-accent { border-left: 3px solid var(--accent); }

/* ========================================
   Admin Layout
   ======================================== */
.admin-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar {
  background: var(--gray-900);
  color: #fff;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.logo-box {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
}
.logo-text { font-weight: 700; font-size: 1.05rem; }

.sidebar-user {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 0.78rem;
}
.sidebar-user strong { display: block; color: #fff; font-size: 0.85rem; margin-bottom: 2px; }
.sidebar-user span { color: rgba(255,255,255,0.5); }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-group {
  padding: 12px 20px 6px;
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.75);
  font-size: 0.87rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--tr);
  border-left: 3px solid transparent;
}
.sidebar-item:hover { background: rgba(255,255,255,0.05); color: #fff; }
.sidebar-item.active {
  background: rgba(99,102,241,0.15);
  color: #fff;
  border-left-color: var(--primary-light);
}
.sidebar-item .material-symbols-rounded { font-size: 20px; }

.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.topbar {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.content-area { padding: 28px; flex: 1; }

/* ========================================
   Participant / Login pages
   ======================================== */
.page-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.brand-hero {
  text-align: center;
  margin-bottom: 24px;
}
.brand-hero img { height: 48px; object-fit: contain; }

/* ========================================
   Test Engine — Participant
   ======================================== */
.test-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
}
.test-topbar {
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.test-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  flex: 1;
  overflow: hidden;
}
.test-content { padding: 28px; overflow-y: auto; }
.test-sidebar {
  background: var(--bg-elev);
  border-left: 1px solid var(--border);
  padding: 20px;
  overflow-y: auto;
}
.test-footer {
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -1px 3px rgba(0,0,0,0.04);
}

.timer-display {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.9rem;
  font-family: 'JetBrains Mono', monospace;
}
.timer-ok { background: var(--success-bg); color: #047857; }
.timer-warn { background: var(--warning-bg); color: #b45309; }
.timer-danger { background: var(--danger-bg); color: #b91c1c; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }

.question-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 820px;
  margin: 0 auto;
  box-shadow: var(--shadow-sm);
}
.question-number {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
.question-text {
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 24px;
  color: var(--text);
}

.option-list { display: flex; flex-direction: column; gap: 10px; }
.option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--tr);
  background: var(--bg-elev);
}
.option-item:hover { border-color: var(--primary-light); background: var(--primary-50); }
.option-item.selected {
  border-color: var(--primary);
  background: var(--primary-50);
  box-shadow: 0 0 0 3px var(--primary-50);
}
.option-radio {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  transition: all var(--tr);
}
.option-item.selected .option-radio {
  border-color: var(--primary);
  background: var(--primary);
}
.option-item.selected .option-radio::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  background: #fff;
  border-radius: 50%;
}
.option-label {
  font-weight: 700;
  color: var(--primary);
  min-width: 24px;
}
.option-text { flex: 1; font-size: 0.95rem; }

/* === IST3 Analogy Stimulus === */
.analogy-stimulus {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px 20px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--primary-50), var(--bg-elev));
  border-radius: var(--radius);
  border: 2px dashed var(--primary-light);
}
.analogy-pair {
  display: flex;
  align-items: center;
  gap: 12px;
}
.analogy-word {
  background: var(--bg-elev);
  padding: 12px 22px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.analogy-sep {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
}
.analogy-equals {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
  padding: 0 8px;
}
.analogy-blank {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
  border-style: dashed;
  min-width: 48px;
  text-align: center;
}

/* === IST7 Number Series Stimulus === */
.number-series-stimulus {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px 20px;
  margin-bottom: 16px;
  background: linear-gradient(135deg, #eef2ff, var(--bg-elev));
  border-radius: var(--radius);
  border: 2px dashed var(--primary-light);
}
.series-cell {
  background: var(--bg-elev);
  min-width: 64px;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.4rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.series-blank {
  background: var(--warning-bg);
  color: var(--warning);
  border-color: var(--warning);
  border-style: dashed;
}
.series-arrow {
  color: var(--primary);
  font-weight: 700;
  font-size: 1.2rem;
}
@media (max-width: 768px) {
  .analogy-word { font-size: 1rem; padding: 8px 14px; }
  .series-cell { font-size: 1.1rem; min-width: 48px; padding: 10px 12px; }
}

/* === Image Stimulus & Image Choice (CFIT, IST8, IST9) === */
.image-stimulus-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0 20px;
  padding: 16px;
  background: var(--bg-elev);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.image-stimulus {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  cursor: zoom-in;
  transition: transform 0.15s;
}
.image-stimulus:hover { transform: scale(1.02); }

/* === Lightbox Modal — full-screen image zoom (mobile-friendly) === */
.img-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.img-lightbox.open {
  opacity: 1;
  pointer-events: auto;
}
.img-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  /* Allow native pinch-zoom on mobile */
  touch-action: pinch-zoom;
  user-select: none;
  -webkit-user-drag: none;
}
.img-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: #fff;
  border: none;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.img-lightbox-hint {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255,255,255,0.7);
  font-size: 0.85rem;
  pointer-events: none;
}
.image-option-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.image-option-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  cursor: pointer;
  transition: all var(--tr);
}
.image-option-item:hover {
  border-color: var(--primary-light);
  background: var(--primary-50);
  transform: translateY(-2px);
}
.image-option-item.selected {
  border-color: var(--primary);
  background: var(--primary-50);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.image-option-label {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.image-option-item.selected .image-option-label {
  background: var(--success);
}
.image-option-img {
  max-width: 100%;
  max-height: 120px;
  object-fit: contain;
  cursor: zoom-in;
}
.image-option-text {
  font-size: 0.85rem;
  text-align: center;
  color: var(--text);
}

/* === IST5 Memory Study & Recall === */
.memory-study-card {
  padding: 20px;
  background: linear-gradient(135deg, var(--primary-50), var(--bg-elev));
  border-radius: var(--radius);
  border: 2px solid var(--primary-light);
}
.memory-study-header {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--primary-light);
}
.memory-study-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}
.memory-cat-card {
  padding: 16px;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.memory-cat-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  font-weight: 800;
  font-size: 1.1rem;
  margin-bottom: 8px;
}
.memory-cat-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.memory-cat-words {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.memory-word {
  display: inline-block;
  padding: 4px 10px;
  background: var(--primary-50);
  color: var(--text);
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid var(--primary-light);
}
.memory-recall-stimulus {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--primary);
  padding: 24px;
  margin: 16px 0 20px;
  background: var(--primary-50);
  border-radius: var(--radius);
  border: 2px dashed var(--primary-light);
}
@media (max-width: 768px) {
  .image-option-grid { grid-template-columns: repeat(2, 1fr); }
  .memory-study-grid { grid-template-columns: 1fr; }
  .memory-recall-stimulus { font-size: 1.3rem; padding: 18px; }
}

.likert-scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.likert-item {
  text-align: center;
  padding: 14px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--tr);
  background: var(--bg-elev);
}
.likert-item:hover { border-color: var(--primary-light); background: var(--primary-50); }
.likert-item.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.likert-value { font-size: 1.5rem; font-weight: 700; margin-bottom: 4px; }
.likert-text { font-size: 0.72rem; opacity: 0.85; }

.q-palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 6px; }
.q-dot {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 600;
  background: #fff;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--tr);
  color: var(--text);
}
.q-dot:hover { border-color: var(--primary); transform: scale(1.05); }
.q-dot.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.q-dot.answered { background: var(--success-bg); border-color: var(--success); color: #047857; }
.q-dot.answered.current { background: var(--primary); border-color: var(--primary); color: #fff; }

.review-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 12px 0; }

.progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--primary));
  transition: width 0.3s ease;
}

/* ========================================
   Instruction & Modal Overlays
   ======================================== */
.instruction-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.instruction-card {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 560px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-xl);
}
.instruction-card h2 { margin-bottom: 12px; font-size: 1.5rem; }
.instruction-card p { color: var(--text-muted); margin-bottom: 20px; line-height: 1.6; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: var(--bg-elev);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.25s ease;
  position: relative;
}
@keyframes slideUp { from { transform: translateY(10px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--tr);
}
.modal-close:hover { background: var(--gray-100); }

.warning-overlay {
  position: fixed;
  inset: 0;
  background: rgba(239, 68, 68, 0.92);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  z-index: 2000;
}
.warning-overlay .material-symbols-rounded { font-size: 72px; margin-bottom: 20px; }
.warning-overlay h2 { color: #fff; font-size: 2rem; margin-bottom: 12px; }

.hidden { display: none !important; }

/* ========================================
   Completed page
   ======================================== */
.completed-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--success), var(--accent));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  padding: 20px;
}
.completed-icon {
  width: 96px;
  height: 96px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  border: 4px solid rgba(255, 255, 255, 0.4);
}
.completed-icon .material-symbols-rounded { font-size: 56px; color: #fff; }
.completed-page h1 { color: #fff; }

/* ========================================
   Video
   ======================================== */
.video-container {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  overflow: hidden;
  margin: 16px 0;
  background: #000;
  border-radius: var(--radius);
}
.video-container iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
}

/* ========================================
   Checkbox items
   ======================================== */
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--tr);
  margin-bottom: 4px;
}
.checkbox-item:hover { background: var(--gray-50); }
.checkbox-box {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  flex-shrink: 0;
  transition: all var(--tr);
  position: relative;
}
.checkbox-item.checked .checkbox-box {
  background: var(--primary);
  border-color: var(--primary);
}
.checkbox-item.checked .checkbox-box::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%) rotate(45deg);
  width: 6px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
}

/* ========================================
   Toast
   ======================================== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 500;
  font-size: 0.9rem;
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  animation: slideInRight 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
  max-width: 400px;
}
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes fadeOut { to { opacity: 0; transform: translateX(100%); } }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
.toast-warning { background: var(--warning); }

/* ========================================
   Utility classes
   ======================================== */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-5 { gap: 20px; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-5 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-5 { margin-bottom: 24px; }
.ml-auto { margin-left: auto; }
.ml-2 { margin-left: 8px; }
.pt-3 { padding-top: 12px; }
.pt-4 { padding-top: 16px; }

.text-xs { font-size: 0.72rem; }
.text-sm { font-size: 0.82rem; }
.text-lg { font-size: 1.1rem; }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

.rounded { border-radius: var(--radius); }
.rounded-sm { border-radius: var(--radius-sm); }
.rounded-full { border-radius: 999px; }

.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }

.h-8 { height: 32px; }
.h-full { height: 100%; }

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 1024px) {
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: -280px; transition: left var(--tr); z-index: 100; width: 260px; }
  .sidebar.open { left: 0; }
  .test-body { grid-template-columns: 1fr; }
  .test-sidebar { display: none; }
}
@media (max-width: 640px) {
  .stat-card { padding: 16px; gap: 12px; }
  .stat-value { font-size: 1.5rem; }
  .content-area { padding: 16px; }
  .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr 1fr; }
  .likert-scale { grid-template-columns: 1fr 1fr; }
  .question-card { padding: 20px; }
}

/* === Mobile Portrait — HP rendering test page === */
/* Untuk HP portrait, layout test harus pas 100vw, gak boleh ada horizontal scroll.
   Topbar/footer wrap, font lebih kecil, button stack vertikal. */
@media (max-width: 480px), (orientation: portrait) and (max-width: 768px) {
  .test-shell {
    width: 100vw;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .test-topbar {
    padding: 8px 12px;
    gap: 8px;
    flex-wrap: wrap;
  }
  .test-topbar > div { flex-wrap: wrap; gap: 6px !important; }
  .test-topbar img { height: 24px !important; max-width: 80px !important; }
  .test-content {
    padding: 14px 12px;
    width: 100%;
    box-sizing: border-box;
  }
  .test-footer {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .test-footer .flex.gap-2 {
    flex-wrap: wrap;
    width: 100%;
    justify-content: stretch;
  }
  .test-footer .btn {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.78rem;
    padding: 8px 12px;
  }
  .timer-display {
    padding: 4px 8px;
    font-size: 0.78rem;
  }
  .question-card {
    padding: 16px 12px;
    margin: 0 0 12px;
  }
  .question-text { font-size: 0.95rem; line-height: 1.5; }
  .option-item, .papi-option, .forced-choice-option {
    padding: 10px 12px;
    font-size: 0.88rem;
  }
  .instruction-overlay {
    padding: 16px 12px !important;
    align-items: flex-start !important;
  }
  .instruction-overlay > div {
    padding: 16px !important;
    margin: 0 !important;
    width: 100% !important;
    box-sizing: border-box;
  }
  /* Webcam preview lebih kecil di HP */
  #camPreviewWrap {
    width: 80px !important;
    height: 60px !important;
    bottom: 8px !important;
    left: 8px !important;
  }
  /* Modal-overlay full-width di HP */
  .modal-overlay .modal-content {
    max-width: 96vw !important;
    margin: 12px;
    padding: 20px 16px;
  }
  /* Tombol modal stack vertikal di HP supaya tidak kepotong */
  .modal-overlay .modal-content .flex.gap-2.justify-center,
  .modal-overlay .modal-content .flex.gap-2 {
    flex-direction: column;
    align-items: stretch;
  }
  .modal-overlay .modal-content .flex.gap-2 > .btn {
    width: 100%;
    white-space: normal;
    line-height: 1.3;
    padding: 10px 14px;
  }
}


/* === Markdown / AI Analysis Body === */
.ai-analysis-body {
  color: var(--text);
}
.ai-analysis-body p {
  margin: 0 0 12px;
  line-height: 1.75;
}
.ai-analysis-body p:last-child { margin-bottom: 0; }

.ai-analysis-body .md-h2 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 22px 0 10px;
  padding: 8px 14px;
  border-left: 4px solid var(--primary);
  background: linear-gradient(90deg, var(--primary-50), transparent);
  border-radius: 4px;
  color: var(--primary);
  letter-spacing: 0.01em;
}
.ai-analysis-body .md-h2:first-child { margin-top: 0; }

.ai-analysis-body .md-h3 {
  font-size: 0.98rem;
  font-weight: 700;
  margin: 18px 0 8px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-analysis-body .md-h3::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
}

.ai-analysis-body .md-h4 {
  font-size: 0.9rem;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ai-analysis-body .md-ul,
.ai-analysis-body .md-ol {
  margin: 8px 0 14px;
  padding-left: 22px;
}
.ai-analysis-body .md-ul li,
.ai-analysis-body .md-ol li {
  margin-bottom: 6px;
  line-height: 1.65;
}
.ai-analysis-body .md-ul li::marker {
  color: var(--primary);
}

.ai-analysis-body strong {
  color: var(--text);
  font-weight: 700;
}
.ai-analysis-body em {
  color: var(--text-muted);
  font-style: italic;
}

.ai-analysis-body .md-code {
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
  color: var(--accent);
}

.ai-analysis-body .md-hr {
  border: none;
  border-top: 1px dashed var(--border);
  margin: 18px 0;
}


/* === Markdown content styling (umum, dipakai untuk instruksi segmen, contoh soal, dll) === */
.md-content {
  line-height: 1.65;
  color: var(--text);
}
.md-content h1, .md-content .md-h1,
.md-content h2, .md-content .md-h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 18px 0 8px;
  color: var(--text);
  letter-spacing: -0.01em;
}
.md-content h2:first-child, .md-content .md-h2:first-child,
.md-content h1:first-child, .md-content .md-h1:first-child {
  margin-top: 0;
}
.md-content h3, .md-content .md-h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin: 14px 0 6px;
  color: var(--text);
}
.md-content h4, .md-content .md-h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 12px 0 4px;
  color: var(--text);
}
.md-content p {
  margin: 0 0 10px;
}
.md-content p:last-child {
  margin-bottom: 0;
}
.md-content strong { font-weight: 700; color: var(--text); }
.md-content em { font-style: italic; }
.md-content ul, .md-content .md-ul,
.md-content ol, .md-content .md-ol {
  margin: 8px 0 12px;
  padding-left: 22px;
}
.md-content ul li, .md-content .md-ul li,
.md-content ol li, .md-content .md-ol li {
  margin-bottom: 4px;
  line-height: 1.55;
}
.md-content ul li::marker, .md-content .md-ul li::marker {
  color: var(--primary);
}
.md-content code, .md-content .md-code {
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}
.md-content hr, .md-content .md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 14px 0;
}
