:root {
  --blue: #1664FF;
  --blue-dark: #0D4ED8;
  --blue-light: #E8F0FF;
  --blue-mid: #3B82F6;
  --green: #10B981;
  --orange: #F59E0B;
  --red: #EF4444;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Banner */
.banner {
  background: #f0f2f5;
  text-align: center;
  overflow: hidden;
}
.banner-img {
  width: 100%;
  max-width: 640px;
  height: auto;
  display: block;
  margin: 0 auto;
  vertical-align: middle;
}
.banner-sub {
  font-size: 13px;
  color: var(--gray-500);
  padding: 10px 16px 12px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  line-height: 1.6;
}

/* Progress */
.progress-wrap {
  background: #fff;
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 100;
}
.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 8px;
}
.progress-header .current { color: var(--blue); font-weight: 700; }
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--blue-mid));
  border-radius: 3px;
  transition: width 0.35s ease;
  width: 0%;
}

.container { padding: 16px 16px 120px; max-width: 600px; margin: 0 auto; }

.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin-bottom: 14px;
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title::before {
  content: '';
  width: 4px;
  height: 16px;
  background: var(--blue);
  border-radius: 2px;
}

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-group input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus { border-color: var(--blue); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 24px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff;
  width: 100%;
}
.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  flex: 1;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--blue);
  color: var(--blue);
  width: 100%;
  margin-top: 10px;
}
.btn-link {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
  padding: 8px;
}

.info-tip {
  background: var(--blue-light);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--blue-dark);
  line-height: 1.6;
  margin-bottom: 14px;
}

/* Quiz */
.q-meta {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.q-tag {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}
.q-text {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.65;
  margin-bottom: 18px;
  color: var(--gray-900);
}

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  background: #fff;
}
.option:hover { border-color: var(--blue-mid); background: var(--blue-light); }
.option.selected {
  border-color: var(--blue);
  background: var(--blue-light);
  box-shadow: 0 0 0 1px var(--blue);
}
.option-key {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--gray-700);
}
.option.selected .option-key {
  background: var(--blue);
  color: #fff;
}
.option-text { font-size: 14px; line-height: 1.55; padding-top: 3px; }

/* Bottom bar */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #fff;
  border-top: 1px solid var(--gray-200);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  gap: 10px;
  z-index: 200;
  max-width: 600px;
  margin: 0 auto;
}

/* Result */
.result-hero {
  text-align: center;
  padding: 24px 16px;
}
.badge-icon { font-size: 64px; margin-bottom: 12px; }
.result-score {
  font-size: 48px;
  font-weight: 800;
  color: var(--blue);
  line-height: 1;
}
.result-score span { font-size: 20px; font-weight: 600; }
.result-label {
  font-size: 16px;
  color: var(--gray-700);
  margin-top: 8px;
  font-weight: 600;
}
.result-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 16px;
}
.stat-item { text-align: center; }
.stat-num { font-size: 24px; font-weight: 700; }
.stat-num.green { color: var(--green); }
.stat-num.red { color: var(--red); }
.stat-label { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Review */
.review-item {
  border-left: 4px solid var(--gray-200);
  padding-left: 14px;
  margin-bottom: 16px;
}
.review-item.correct { border-left-color: var(--green); }
.review-item.wrong { border-left-color: var(--red); }
.review-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.review-status { font-size: 13px; font-weight: 700; }
.review-item.correct .review-status { color: var(--green); }
.review-item.wrong .review-status { color: var(--red); }
.review-q { font-size: 14px; line-height: 1.6; margin-bottom: 8px; }
.review-ans {
  font-size: 13px;
  background: var(--gray-50);
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 6px;
}
.review-explain {
  font-size: 13px;
  background: #FFF7ED;
  color: #92400E;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.6;
}

.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 14px 24px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

.loading {
  text-align: center;
  padding: 40px;
  color: var(--gray-500);
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.nav-tabs {
  display: flex;
  gap: 0;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}
.nav-tab {
  flex: 1;
  padding: 12px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.nav-tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

.already-done-card {
  text-align: center;
  padding: 8px 0;
}
.already-done-card .score-big {
  font-size: 42px;
  font-weight: 800;
  color: var(--blue);
  margin: 12px 0 4px;
}
