@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@600;700;800&display=swap');

:root{
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f8f7;
  --text: #14161a;
  --text-soft: #6b7280;
  --border: #e7eae9;
  --accent: #1fb463;
  --accent-dark: #16904e;
  --accent-soft: #e7f8ee;
  --danger: #e5484d;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 10px rgba(20, 22, 26, 0.05);
  --shadow-md: 0 10px 30px rgba(20, 22, 26, 0.08);
  --shadow-lg: 0 20px 50px rgba(20, 22, 26, 0.12);
  --ease: cubic-bezier(.22,1,.36,1);
}

*{ box-sizing: border-box; }

html, body{
  margin:0; padding:0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,h2,h3,h4{
  font-family: 'Poppins', 'Inter', sans-serif;
  margin: 0;
  letter-spacing: -0.02em;
}

a{ color: inherit; text-decoration: none; }

.container{
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ---------- top nav ---------- */
.topbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top:0;
  z-index: 20;
}
.brand{
  display:flex;
  align-items:center;
  gap:10px;
  font-family: 'Poppins', sans-serif;
  font-weight:700;
  font-size: 19px;
}
.brand .dot{
  width:10px; height:10px; border-radius:50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.nav-link{
  font-weight:600;
  font-size:14px;
  color: var(--text-soft);
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: all .2s var(--ease);
}
.nav-link:hover{
  color: var(--accent-dark);
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

/* ---------- buttons ---------- */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  padding: 12px 22px;
  border-radius: 999px;
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  cursor: pointer;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s var(--ease), opacity .18s var(--ease);
}
.btn-primary{
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px rgba(31, 180, 99, 0.28);
}
.btn-primary:hover{ background: var(--accent-dark); transform: translateY(-2px); box-shadow: 0 12px 26px rgba(31,180,99,.35); }
.btn-primary:active{ transform: translateY(0px) scale(.98); }
.btn-primary:disabled{ opacity:.4; cursor:not-allowed; transform:none; box-shadow:none; }

.btn-ghost{
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover{ border-color: var(--accent); color: var(--accent-dark); transform: translateY(-1px); }

.btn-danger{
  background: #fff;
  color: var(--danger);
  border: 1px solid #f3c8c9;
}
.btn-danger:hover{ background: #fdf1f1; transform: translateY(-1px); }

.btn-sm{ padding: 8px 14px; font-size: 13px; border-radius: 999px; }

/* ---------- cards ---------- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), border-color .2s var(--ease);
}
.card:hover{
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: #d7ecdf;
}

.test-card{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 16px;
  margin-bottom: 16px;
  animation: fadeUp .45s var(--ease) both;
}
.test-card .meta{ color: var(--text-soft); font-size: 13.5px; margin-top:6px; }
.test-card h3{ font-size: 18px; }

/* ---------- progress / quiz top bar ---------- */
.quiz-head{
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 24px 0;
}
.quiz-stats{
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 10px;
}
.quiz-stats .timer{
  display:flex; align-items:center; gap:6px;
  color: var(--text);
  background: var(--surface-2);
  padding: 5px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.quiz-stats .timer.low{ color: var(--danger); border-color:#f3c8c9; background:#fdf1f1; }

.progress-track{
  width:100%;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow:hidden;
  border: 1px solid var(--border);
}
.progress-fill{
  height:100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-dark));
  border-radius: 999px;
  transition: width .4s var(--ease);
}

/* ---------- question ---------- */
.quiz-body{
  max-width: 720px;
  margin: 0 auto;
  padding: 36px 24px 60px;
}
.question-box{
  animation: fadeScaleIn .38s var(--ease);
}
.q-index-label{
  color: var(--accent-dark);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.question-text{
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 28px;
}

.answers{
  display:grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
.answer-option{
  display:flex;
  align-items:center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 15.5px;
  font-weight: 500;
  transition: transform .16s var(--ease), border-color .16s var(--ease), background .16s var(--ease), box-shadow .16s var(--ease);
}
.answer-option:hover{
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}
.answer-option .letter{
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display:flex; align-items:center; justify-content:center;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-soft);
  transition: all .16s var(--ease);
}
.answer-option.selected{
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 6px 18px rgba(31,180,99,.18);
  transform: scale(1.01);
}
.answer-option.selected .letter{
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.quiz-footer{
  display:flex;
  justify-content:flex-end;
  margin-top: 30px;
  min-height: 48px;
}
.quiz-footer .btn{
  animation: fadeUp .3s var(--ease);
}

/* ---------- result page ---------- */
.result-hero{
  text-align:center;
  padding: 50px 20px 30px;
  animation: fadeScaleIn .5s var(--ease);
}
.result-score{
  font-family:'Poppins',sans-serif;
  font-size: 64px;
  font-weight: 800;
  color: var(--accent-dark);
  line-height:1;
}
.result-sub{ color: var(--text-soft); margin-top: 10px; font-size:15px; }
.result-list{ display:flex; flex-direction:column; gap:12px; margin-top: 30px; }
.result-item{
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  animation: fadeUp .4s var(--ease) both;
}
.result-item.correct{ border-left: 4px solid var(--accent); }
.result-item.wrong{ border-left: 4px solid var(--danger); }
.result-item .q{ font-weight:600; margin-bottom:6px; }
.result-item .a{ font-size: 13.5px; color: var(--text-soft); }
.result-item .a.your-wrong{ color: var(--danger); }
.result-item .a.answer-correct{ color: var(--accent-dark); }

/* ---------- forms (admin) ---------- */
.field{ margin-bottom: 16px; }
.field label{ display:block; font-size: 13px; font-weight:600; color: var(--text-soft); margin-bottom: 6px; }
.field input[type=text], .field input[type=number], .field textarea{
  width:100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-family:'Inter',sans-serif;
  font-size: 14.5px;
  background: var(--surface-2);
  transition: border-color .16s var(--ease), background .16s var(--ease);
}
.field input:focus, .field textarea:focus{
  outline:none;
  border-color: var(--accent);
  background: #fff;
}
.field textarea{ resize: vertical; min-height: 64px; }

.answer-row{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom: 10px;
}
.answer-row input[type=text]{ flex:1; }
.answer-row input[type=radio]{ accent-color: var(--accent); width:18px; height:18px; }

.empty-state{
  text-align:center;
  padding: 60px 20px;
  color: var(--text-soft);
  animation: fadeUp .4s var(--ease);
}

.section-title{
  display:flex; align-items:center; justify-content:space-between;
  margin: 34px 0 14px;
}

.q-admin-item{
  border:1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  margin-bottom: 12px;
  animation: fadeUp .3s var(--ease) both;
}
.q-admin-item .q-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:12px; }
.q-admin-item .q-answers{ margin-top:10px; font-size:13.5px; color: var(--text-soft); display:grid; gap:4px; }
.q-admin-item .q-answers .is-correct{ color: var(--accent-dark); font-weight:600; }
.q-admin-item .actions{ display:flex; gap:8px; flex:none; }

.modal-overlay{
  position:fixed; inset:0;
  background: rgba(15,17,20,.45);
  display:flex; align-items:center; justify-content:center;
  z-index: 100;
  padding: 20px;
  animation: fadeIn .2s var(--ease);
}
.modal{
  background:#fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 86vh;
  overflow-y:auto;
  animation: fadeScaleIn .25s var(--ease);
}
.modal h3{ margin-bottom: 18px; font-size: 20px; }
.modal-actions{ display:flex; justify-content:flex-end; gap:10px; margin-top: 20px; }

/* ---------- animations ---------- */
@keyframes fadeScaleIn{
  from{ opacity:0; transform: scale(.96) translateY(6px); }
  to{ opacity:1; transform: scale(1) translateY(0); }
}
@keyframes fadeUp{
  from{ opacity:0; transform: translateY(10px); }
  to{ opacity:1; transform: translateY(0); }
}
@keyframes fadeIn{
  from{ opacity:0; } to{ opacity:1; }
}

@media (max-width: 560px){
  .question-text{ font-size:20px; }
  .result-score{ font-size:48px; }
}