:root {
  --bg: #f7fafc;
  --card: #ffffff;
  --ink: #111827;
  --muted: #4b5563;
  --brand: #2563eb;
  --brand-2: #7c3aed;
  --ok: #0f766e;
  --warn: #b45309;
  --error: #b91c1c;
  --line: #e5e7eb;
  --accent: #06b6d4;
}

/* Page */
html, body {
  margin: 0;
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans";
  background: linear-gradient(180deg, #eef2ff, #ecfeff 40%, #f7fafc);
}
.wrap {
  max-width: 980px;
  margin: auto;
  padding: 16px;
}

/* Header */
header {
  background: linear-gradient(135deg, #bfdbfe, #c7d2fe);
  border-radius: 14px;
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
}
h1 {
  font-size: 1.7rem;
  margin: 0 0 6px 0;
}
.meta {
  color: var(--muted);
  font-size: 0.95rem;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.pill {
  background: #fff;
  border: 1px solid #c7d2fe;
  padding: 2px 8px;
  border-radius: 999px;
  color: #3730a3;
  font-weight: 600;
}
.instructions {
  font-size: 0.98rem;
  color: var(--muted);
  margin-top: 10px;
}

/* Cards and sections */
.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 3px 10px rgba(0,0,0,0.06);
  border: 1px solid var(--line);
}
h2 {
  font-size: 1.25rem;
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
h2 .tag {
  font-size: 0.8rem;
  color: white;
  background: var(--brand);
  padding: 2px 8px;
  border-radius: 999px;
}
.section-meta {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

/* Questions */
.q {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.q-title {
  font-weight: 700;
  margin-bottom: 8px;
}
.q-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.passage {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

/* Inputs */
.choices label {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px dashed transparent;
  cursor: pointer;
}
.choices label:hover, .choices label:focus-within {
  background: #f8fafc;
}
.choices input {
  margin-right: 8px;
}
textarea, input[type="text"] {
  width: 100%;
  min-height: 76px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 1rem;
  resize: vertical;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}
@media (max-width: 720px) {
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Buttons */
.btns {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
button {
  background: var(--brand);
  color: white;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
}
button.secondary {
  background: #111827;
}
button.link {
  background: transparent;
  color: var(--brand);
  border: 2px solid var(--brand);
}
button.ghost {
  background: transparent;
  color: #111827;
  border: 2px dashed #9ca3af;
}

/* Feedback */
.score {
  margin-top: 8px;
  font-weight: 800;
}
.alert {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #ecfeff;
  border: 1px solid #bae6fd;
}
.key {
  background: #fff7ed;
  border: 1px solid #fed7aa;
}
.correct { color: var(--ok); }
.incorrect { color: var(--error); }
.footer-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 8px;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--brand-2);
}
.sticky-actions {
  position: sticky;
  bottom: 8px;
  z-index: 10;
  background: linear-gradient(180deg, rgba(255,255,255,0), #ffffff 12%, #ffffff);
  padding-top: 10px;
}
.rubric {
  background: #fefce8;
  border: 1px solid #fde68a;
  padding: 10px;
  border-radius: 8px;
  margin-top: 8px;
}
.save-indicator {
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}

/* Accessibility helpers */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}