:root {
  --bg: #0f1117;
  --surface: #1a1d2e;
  --surface2: #232640;
  --border: #2e3250;
  --accent: #6c63ff;
  --accent-hover: #8b85ff;
  --green: #4ade80;
  --red: #f87171;
  --yellow: #facc15;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --radius: 10px;
}

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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

/* Layout */
.container { max-width: 860px; margin: 0 auto; padding: 2rem 1.5rem; }

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
header a { text-decoration: none; color: var(--text); font-weight: 700; font-size: 1.2rem; }
header span { color: var(--accent); }

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  margin-bottom: 1.25rem;
}
.card h2 { font-size: 1.1rem; margin-bottom: 1rem; color: var(--text); }

/* Hero */
.hero { text-align: center; padding: 4rem 2rem; }
.hero h1 { font-size: 2.5rem; font-weight: 800; margin-bottom: 0.5rem; }
.hero h1 span { color: var(--accent); }
.hero p { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 2.5rem; }

.action-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 2rem; }
.action-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s;
  text-decoration: none;
  color: var(--text);
  display: block;
}
.action-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.action-card .icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.action-card h3 { font-size: 1.1rem; margin-bottom: 0.4rem; }
.action-card p { color: var(--text-muted); font-size: 0.9rem; }

/* Forms */
.form-group { margin-bottom: 1.25rem; }
label { display: block; font-size: 0.875rem; color: var(--text-muted); margin-bottom: 0.4rem; font-weight: 500; }
input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 0.6rem 0.85rem;
  font-size: 0.95rem;
  font-family: inherit;
  transition: border-color 0.2s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 120px; }

.num-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.5rem;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-full { width: 100%; justify-content: center; }

/* Question cards */
.question-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}
.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}
.question-num { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.points-badge {
  font-size: 0.78rem;
  background: var(--border);
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  color: var(--text-muted);
}
.question-text { font-size: 1rem; margin-bottom: 1rem; }

/* MCQ options */
.options { display: flex; flex-direction: column; gap: 0.5rem; }
.option-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.option-label:hover { border-color: var(--accent); background: rgba(108,99,255,0.07); }
.option-label input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
.option-label.selected { border-color: var(--accent); background: rgba(108,99,255,0.12); }

/* Fill blank */
.fill-blank-text { font-size: 1rem; margin-bottom: 0.75rem; }
.blank-input { display: inline-block; width: auto; min-width: 180px; }

/* Code textarea */
.code-area {
  font-family: 'Courier New', Consolas, monospace;
  font-size: 0.875rem;
  min-height: 150px;
  tab-size: 4;
}

/* Results */
.score-banner {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}
.grade-letter {
  font-size: 4rem;
  font-weight: 900;
  line-height: 1;
  margin-bottom: 0.25rem;
}
.grade-A { color: var(--green); }
.grade-B { color: #60d394; }
.grade-C { color: var(--yellow); }
.grade-D { color: #fb923c; }
.grade-F { color: var(--red); }
.score-text { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.25rem; }
.score-sub { color: var(--text-muted); }

.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0 0.5rem;
}
.progress-fill { height: 100%; border-radius: 4px; background: var(--accent); transition: width 1s ease; }

.overall-feedback {
  background: rgba(108,99,255,0.1);
  border-left: 3px solid var(--accent);
  padding: 1rem 1.25rem;
  border-radius: 0 6px 6px 0;
  margin-bottom: 1.5rem;
  font-size: 0.95rem;
}

.result-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.result-card.correct { border-left: 3px solid var(--green); }
.result-card.incorrect { border-left: 3px solid var(--red); }
.result-card.partial { border-left: 3px solid var(--yellow); }

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}
.result-score { font-weight: 700; font-size: 0.95rem; white-space: nowrap; margin-left: 1rem; }
.result-score.full { color: var(--green); }
.result-score.partial { color: var(--yellow); }
.result-score.zero { color: var(--red); }

.answer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 0.75rem 0; }
.answer-box { background: var(--bg); border-radius: 6px; padding: 0.75rem; font-size: 0.875rem; }
.answer-box .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; }
.answer-box pre { white-space: pre-wrap; font-family: 'Courier New', monospace; font-size: 0.85rem; }

.feedback-box {
  background: var(--bg);
  border-radius: 6px;
  padding: 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}
.feedback-box .label { font-size: 0.75rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; font-weight: 600; }

/* Spinner */
.spinner-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 60vh; gap: 1rem; }
.spinner { width: 48px; height: 48px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Alerts */
.alert { padding: 0.75rem 1rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert-error { background: rgba(248,113,113,0.1); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }

/* Take exam header */
.exam-meta { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.meta-pill {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Student name step */
.name-step { max-width: 420px; margin: 4rem auto; text-align: center; }
.name-step h2 { margin-bottom: 0.5rem; }
.name-step p { color: var(--text-muted); margin-bottom: 1.5rem; }

@media (max-width: 600px) {
  .action-cards { grid-template-columns: 1fr; }
  .num-row { grid-template-columns: 1fr; }
  .answer-row { grid-template-columns: 1fr; }
  .hero h1 { font-size: 1.8rem; }
}
