:root {
  --primary: #6c5ce7;
  --primary-dark: #5640d4;
  --secondary: #74b9ff;
  --success: #00b894;
  --danger: #e74c3c;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --text: #2d3436;
  --muted: #6b7280;
  --radius: 16px;
  --shadow: 0 8px 24px rgba(108, 92, 231, 0.12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: linear-gradient(135deg, #eef0fb 0%, #e8f1fb 100%);
  color: var(--text);
  min-height: 100vh;
}

.app-header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  padding: 28px 16px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
}

.app-header h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: 1px;
}

.subtitle {
  margin: 4px 0 0;
  opacity: 0.95;
  font-weight: 400;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  margin-bottom: 24px;
  animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden { display: none !important; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.status-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0;
}

.badge {
  background: #f1f0fe;
  color: var(--primary-dark);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
}

.upload-box {
  border: 2px dashed #d6d9f5;
  border-radius: var(--radius);
  padding: 20px;
  margin: 20px 0;
  background: #fafaff;
}

.upload-box h3 { margin-top: 0; }

.upload-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

#paste-area {
  margin-top: 12px;
}

#json-text-input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #d6d9f5;
  padding: 12px;
  font-family: monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.feedback {
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 1.2em;
}

.feedback.success { color: var(--success); }
.feedback.error { color: var(--danger); }

.center { text-align: center; }
.center-text { text-align: center; }

.text-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #d6d9f5;
  font-size: 1rem;
  margin: 12px 0;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 24px 0;
}

.pill {
  border: 2px solid #e6e8f5;
  background: white;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pill:hover {
  border-color: var(--primary);
}

.pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(108, 92, 231, 0.35);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
}
.btn-secondary:hover:not(:disabled) {
  background: #5aa3f0;
  transform: translateY(-2px);
}

.btn-outline {
  background: white;
  color: var(--primary-dark);
  border: 2px solid var(--primary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--primary);
  color: white;
}

.btn-success {
  background: var(--success);
  color: white;
}
.btn-success:hover:not(:disabled) {
  background: #019875;
  transform: translateY(-2px);
}

.btn-large {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  margin-top: 8px;
}

.progress-row {
  margin-bottom: 20px;
}

#progress-text {
  font-weight: 600;
  color: var(--primary-dark);
}

.progress-bar {
  background: #ecebfd;
  border-radius: 999px;
  height: 8px;
  margin-top: 8px;
  overflow: hidden;
}

#progress-fill {
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

#question-text {
  margin: 8px 0 20px;
  font-size: 1.25rem;
  line-height: 1.4;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid #e6e8f5;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fff;
}

.option-item:hover {
  border-color: var(--primary);
  background: #f8f7ff;
  transform: translateX(4px);
}

.option-item.selected {
  border-color: var(--primary);
  background: #efeaff;
  font-weight: 600;
}

.option-item input {
  pointer-events: none;
}

.option-item.correct {
  border-color: var(--success);
  background: #e6f9f2;
  color: #016a4f;
  font-weight: 600;
}

.option-item.incorrect {
  border-color: var(--danger);
  background: #fdecea;
  color: #9c241a;
  font-weight: 600;
}

.nav-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.nav-row .btn { flex: 1; }

.score-circle {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  margin: 20px auto;
  box-shadow: var(--shadow);
}

.review-list {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.review-item {
  border: 1px solid #e6e8f5;
  border-left: 4px solid #e6e8f5;
  border-radius: 12px;
  padding: 16px;
}

.review-item.review-wrong {
  border-left-color: var(--danger);
}

.review-item.review-correct {
  border-left-color: var(--success);
}

.answer-line {
  margin: 12px 0 0;
  font-size: 0.9rem;
}

.ans-correct {
  color: #016a4f;
  font-weight: 700;
}

.ans-wrong {
  color: #9c241a;
  font-weight: 700;
}

.review-item .q-title {
  font-weight: 600;
  margin-bottom: 10px;
}

.review-item .tag {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 10px;
  border-radius: 999px;
  margin-left: 8px;
  font-weight: 700;
}

.tag.correct-tag { background: #e6f9f2; color: #016a4f; }
.tag.wrong-tag { background: #fdecea; color: #9c241a; }

.app-footer {
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 480px) {
  .app-header h1 { font-size: 1.7rem; }
  .card { padding: 18px; }
  .nav-row { flex-direction: column; }
  .score-circle { width: 110px; height: 110px; font-size: 1.6rem; }
}
