:root {
  --bg:          #0a1a0f;
  --bg-card:     #112318;
  --bg-hover:    #1a3326;
  --primary:     #22c55e;
  --primary-dim: #16a34a;
  --accent:      #4ade80;
  --success:     #22c55e;
  --error:       #ef4444;
  --warning:     #f59e0b;
  --text:        #f0fdf4;
  --text-muted:  #86efac;
  --border:      #1e4d2b;
  --shadow:      0 4px 24px rgba(34,197,94,0.08);
  --radius:      12px;
  --font:        -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* --- Cards --- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.4rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s, transform 0.1s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #0a1a0f; }
.btn-primary:hover { background: var(--accent); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: #7f1d1d; color: #fca5a5; }
.btn-danger:hover { background: #991b1b; }

/* --- Inputs --- */
input, textarea {
  background: #0d2015;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 0.65rem 1rem;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  font-family: var(--font);
}
input:focus, textarea:focus { border-color: var(--primary); }

/* --- Stat cards row --- */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1rem;
  text-align: center;
}
.stat-card .value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary);
}
.stat-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}
.stat-card.due-highlight .value { color: var(--warning); }

/* --- Bar chart --- */
.bar-chart { display: flex; flex-direction: column; gap: 0.6rem; }
.bar-row { display: flex; align-items: center; gap: 0.75rem; font-size: 0.85rem; }
.bar-label { width: 130px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.bar-track { flex: 1; background: #0d2015; border-radius: 4px; height: 16px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--error); border-radius: 4px; transition: width 0.5s; }
.bar-fill.green { background: var(--primary); }
.bar-value { width: 42px; text-align: right; font-size: 0.8rem; color: var(--text-muted); }

/* --- Heatmap --- */
.heatmap { display: flex; gap: 6px; }
.heatmap-day {
  flex: 1; aspect-ratio: 1;
  border-radius: 4px;
  background: #0d2015;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 0.65rem; color: var(--text-muted); gap: 2px;
  transition: background 0.2s;
}
.heatmap-day .day-count { font-weight: 700; color: var(--text); font-size: 0.8rem; }

/* --- Mode grid --- */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}
.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.2rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
}
.mode-card:hover { background: var(--bg-hover); border-color: var(--primary); transform: translateY(-2px); }
.mode-card .mode-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.mode-card .mode-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.mode-card .mode-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.3rem; }

/* --- Upload zone --- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: #0d2015;
}
.upload-zone p { margin: 0.5rem 0; }
.upload-zone .upload-icon { font-size: 2.5rem; }

/* --- Session page --- */
.session-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  position: sticky; top: 0; z-index: 10;
}
.session-progress { flex: 1; max-width: 300px; }
.progress-bar-track { background: #0d2015; border-radius: 99px; height: 6px; margin-top: 4px; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.3s; }

.question-meta { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.meta-tag {
  background: #0d2015; border: 1px solid var(--border);
  border-radius: 99px; padding: 0.2rem 0.7rem; font-size: 0.75rem; color: var(--text-muted);
}

.question-text {
  font-size: 1.1rem; line-height: 1.7; color: var(--text);
  margin-bottom: 1.5rem;
}

/* --- Answer options --- */
.options { display: flex; flex-direction: column; gap: 0.6rem; }
.option {
  display: flex; align-items: flex-start; gap: 0.75rem;
  background: #0d2015;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-size: 1rem;
  line-height: 1.5;
}
.option:hover:not(.locked) { border-color: var(--primary); background: var(--bg-hover); }
.option .opt-letter {
  font-weight: 700; color: var(--primary); min-width: 22px;
  flex-shrink: 0; padding-top: 1px;
}
.option.correct  { border-color: var(--success); background: rgba(34,197,94,0.1); }
.option.wrong    { border-color: var(--error);   background: rgba(239,68,68,0.1); }
.option.locked   { cursor: default; }

/* --- Feedback zone --- */
.feedback-zone { margin-top: 1.5rem; animation: fadeIn 0.3s; }
@keyframes fadeIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }
.feedback-banner {
  padding: 0.8rem 1rem; border-radius: 8px; font-weight: 600; font-size: 1rem; margin-bottom: 1rem;
}
.feedback-banner.correct { background: rgba(34,197,94,0.15); color: var(--success); border: 1px solid var(--success); }
.feedback-banner.wrong   { background: rgba(239,68,68,0.15);  color: var(--error);   border: 1px solid var(--error); }
.explanation-box { color: var(--text-muted); font-size: 0.9rem; line-height: 1.6; margin-bottom: 1rem; }

/* --- Notes textarea --- */
.notes-label { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }
.notes-area { height: 70px; resize: vertical; font-size: 0.9rem; }

/* --- Rating buttons --- */
.rating-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.rating-btn {
  flex: 1; min-width: 70px;
  padding: 0.5rem 0.6rem;
  border-radius: 8px; border: 1px solid var(--border);
  background: #0d2015; color: var(--text);
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
  transition: background 0.15s, border-color 0.15s;
}
.rating-btn:hover { background: var(--bg-hover); border-color: var(--primary); }
.rating-btn[data-r="1"]:hover { border-color: var(--error); background: rgba(239,68,68,0.1); }
.rating-btn[data-r="4"]:hover { border-color: var(--success); background: rgba(34,197,94,0.1); }
.rating-btn.selected { border-color: var(--primary); background: rgba(34,197,94,0.15); color: var(--primary); }

.confidence-row { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; }
.conf-btn {
  flex: 1; padding: 0.45rem 0.5rem;
  border-radius: 8px; border: 1px solid var(--border);
  background: #0d2015; color: var(--text-muted);
  cursor: pointer; font-size: 0.82rem;
  transition: background 0.15s, border-color 0.15s;
}
.conf-btn:hover, .conf-btn.selected {
  border-color: var(--primary); background: var(--bg-hover); color: var(--text);
}

/* --- Timer --- */
.exam-timer {
  font-family: monospace; font-size: 1.1rem; font-weight: 700;
  color: var(--warning); background: #1c1200; border: 1px solid var(--warning);
  border-radius: 6px; padding: 0.3rem 0.75rem;
}
.exam-timer.urgent { color: var(--error); border-color: var(--error); background: #1c0000; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

/* --- Trigger mode --- */
.trigger-keywords {
  font-size: 1.4rem; font-weight: 700; color: var(--accent);
  letter-spacing: 0.03em; line-height: 1.8; text-align: center;
  padding: 2rem; animation: fadeIn 0.4s;
}
.question-reveal { animation: fadeIn 0.4s; }

/* --- Results screen --- */
.results-screen { max-width: 700px; margin: 2rem auto; padding: 1rem; }
.results-score {
  font-size: 3rem; font-weight: 900; color: var(--primary); text-align: center; margin: 1rem 0;
}
.wrong-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 400px; overflow-y: auto; }
.wrong-item {
  background: #0d2015; border: 1px solid var(--border);
  border-radius: 8px; padding: 0.75rem 1rem; font-size: 0.87rem;
}
.wrong-item .q-id { color: var(--text-muted); font-size: 0.75rem; }

/* --- Table --- */
table { width: 100%; border-collapse: collapse; font-size: 0.87rem; }
th, td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; }
td { color: var(--text); }
tr:last-child td { border-bottom: none; }

/* --- Footer --- */
.site-footer {
  text-align: center;
  padding: 2rem 1rem 1.5rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}
.rainbow {
  background: linear-gradient(90deg, #f00, #ff7700, #ff0, #0f0, #0af, #a0f, #f00);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: rainbow-shift 3s linear infinite;
  font-weight: 700;
}
@keyframes rainbow-shift {
  from { background-position: 0% center; }
  to   { background-position: 200% center; }
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-dim); }

/* --- Toast --- */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 1000;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.8rem 1.2rem; font-size: 0.9rem;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  animation: slideUp 0.3s;
}
@keyframes slideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: none; } }
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--error);   color: var(--error); }

/* --- Modal --- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.75);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
  width: min(420px, 92vw);
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.5rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* --- Student list --- */
.student-item {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 0.6rem; overflow: hidden;
}
.student-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.85rem 1rem; cursor: pointer; user-select: none;
  transition: background 0.15s;
}
.student-header:hover { background: var(--bg-hover); }
.student-name { font-weight: 600; font-size: 0.95rem; }
.student-meta { font-size: 0.78rem; color: var(--text-muted); }
.student-chevron { color: var(--text-muted); font-size: 0.75rem; transition: transform 0.2s; }
.student-item.open .student-chevron { transform: rotate(180deg); }
.student-detail {
  padding: 1rem; border-top: 1px solid var(--border);
  display: none; animation: fadeIn 0.2s;
}
.student-item.open .student-detail { display: block; }
.student-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem; margin-bottom: 1rem;
}
.student-stat { text-align: center; }
.student-stat .val { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.student-stat .lbl { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.15rem; }
.mini-heatmap { display: flex; gap: 4px; margin-top: 0.5rem; }
.mini-day {
  flex: 1; aspect-ratio: 1; border-radius: 3px;
  background: #0d2015;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.6rem; color: var(--text-muted);
}
