@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800;900&display=swap');

/* ══════════════════════════════════════════════
   Variables & Reset
══════════════════════════════════════════════ */
:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #e0e7ff;
  --success: #16a34a;
  --success-light: #dcfce7;
  --error: #dc2626;
  --error-light: #fee2e2;
  --warning: #d97706;
  --bg: #f0f4f8;
  --card: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(79,70,229,0.10);
  --radius: 16px;
  --radius-sm: 10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; overflow-x: hidden; }

body {
  overflow-x: hidden;
  font-family: 'Tajawal', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.7;
}

/* ══════════════════════════════════════════════
   Header / Hero
══════════════════════════════════════════════ */
.hero {
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
  color: white;
  padding: 48px 24px 48px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}
.hero h1 { font-size: 2.4rem; font-weight: 900; margin-bottom: 10px; letter-spacing: -0.5px; }
.hero p  { font-size: 1.1rem; opacity: 0.85; font-weight: 400; }
.hero-icon { font-size: 3.5rem; display: block; margin-bottom: 16px; }

/* ══════════════════════════════════════════════
   Layout
══════════════════════════════════════════════ */
.container {
  max-width: 760px;
  margin: 32px auto 48px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
@media (max-width: 700px) {
  .container { margin-top: 20px; padding: 0 12px; }
  .hero h1 { font-size: 1.7rem; }
}

/* ── Admin Toggle Bar ── */
.admin-toggle-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}
.btn-admin-toggle {
  background: transparent;
  border: 1.5px dashed #cbd5e1;
  color: var(--text-muted);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 7px 18px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-admin-toggle:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.btn-admin-toggle.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

/* Admin Panel */
.admin-panel { display: none; }
.admin-panel.visible { display: block; }

/* Admin PIN prompt */
.admin-pin-prompt {
  text-align: center;
  padding: 28px 24px;
}
.admin-pin-prompt p { color: var(--text-muted); font-size: 0.92rem; margin-bottom: 14px; }
.admin-pin-prompt .pin-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.admin-pin-prompt input {
  max-width: 160px;
  text-align: center;
  font-size: 1.2rem;
  letter-spacing: 6px;
  font-weight: 700;
}
.admin-pin-prompt .pin-error {
  color: var(--error);
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 20px;
}
.admin-verified { display: none; }
.admin-verified.visible { display: block; }

/* ══════════════════════════════════════════════
   Card
══════════════════════════════════════════════ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
  border: 1px solid var(--border);
}
.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h2 .icon { font-size: 1.3rem; }

/* ══════════════════════════════════════════════
   Upload Area
══════════════════════════════════════════════ */
.upload-drop {
  border: 2.5px dashed #a5b4fc;
  border-radius: var(--radius-sm);
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: #f8f7ff;
  margin-bottom: 16px;
}
.upload-drop:hover, .upload-drop.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.upload-drop .drop-icon { font-size: 2.5rem; display: block; margin-bottom: 8px; }
.upload-drop p { color: var(--text-muted); font-size: 0.92rem; }
.upload-drop strong { color: var(--primary); }
.file-chosen { color: var(--success); font-weight: 600; font-size: 0.9rem; margin-top: 6px; }

/* ══════════════════════════════════════════════
   Form Elements
══════════════════════════════════════════════ */
.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-group .optional { font-weight: 400; font-size: 0.8rem; }
input[type="text"], input[type="password"] {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  color: var(--text);
  background: #fafafa;
  direction: rtl;
  transition: border-color 0.2s;
  outline: none;
}
input:focus { border-color: var(--primary); background: white; }
input::placeholder { color: #cbd5e1; }

/* ══════════════════════════════════════════════
   Buttons
══════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary {
  background: var(--primary);
  color: white;
  width: 100%;
  font-size: 1.05rem;
  padding: 13px;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); }
.btn-primary:disabled { background: #a5b4fc; cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
  font-size: 0.88rem;
  padding: 7px 14px;
}
.btn-outline:hover { background: var(--primary-light); }
.btn-danger {
  background: var(--error-light);
  color: var(--error);
  border: none;
  font-size: 0.85rem;
  padding: 6px 12px;
}
.btn-danger:hover { background: #fecaca; }

/* ══════════════════════════════════════════════
   Progress / Status
══════════════════════════════════════════════ */
.upload-status { margin-top: 14px; display: none; }
.upload-status.visible { display: block; }
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
  direction: ltr;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s ease;
  animation: pulse-bar 1.5s ease infinite;
}
@keyframes pulse-bar {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.status-text { font-size: 0.88rem; color: var(--text-muted); text-align: center; }

/* ══════════════════════════════════════════════
   Alert / Toast
══════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  margin-top: 12px;
  display: none;
}
.alert.visible { display: block; }
.alert-success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-error   { background: var(--error-light);   color: var(--error);   border: 1px solid #fecaca; }

/* ══════════════════════════════════════════════
   Quiz List
══════════════════════════════════════════════ */
.quiz-list { display: flex; flex-direction: column; gap: 12px; }
.quiz-item {
  background: #f8f9ff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
}
.quiz-item:hover { border-color: #a5b4fc; background: var(--primary-light); }
.quiz-item-info { flex: 1; min-width: 0; }
.quiz-item-title { font-weight: 700; font-size: 0.97rem; color: var(--text); line-height: 1.3; word-break: break-word; }
.quiz-item-meta  { font-size: 0.8rem; color: var(--text-muted); margin-top: 3px; }
.quiz-item-actions { display: flex; gap: 6px; flex-shrink: 0; }
.loading-msg { color: var(--text-muted); font-size: 0.9rem; text-align: center; padding: 24px 0; }

/* Footer */
.site-footer {
  text-align: center;
  padding: 16px 20px;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  background: white;
  margin-top: auto;
}
.site-footer strong { color: var(--primary); }

/* ══════════════════════════════════════════════
   ═══════════ MULTIPLE CHOICE ═══════════
══════════════════════════════════════════════ */
.mc-options { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.mc-btn {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 16px; border-radius: 12px; border: 2px solid var(--border);
  background: white; font-family: 'Tajawal', sans-serif; font-size: 0.95rem;
  cursor: pointer; text-align: right; transition: all 0.18s; color: var(--text);
}
.mc-btn:hover:not(:disabled) { border-color: var(--primary); background: #f0f0ff; }
.mc-letter {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary); color: white; font-weight: 700; font-size: 0.9rem;
}
.mc-btn.selected-correct { border-color: var(--success); background: #f0fdf4; }
.mc-btn.selected-correct .mc-letter { background: var(--success); }
.mc-btn.selected-wrong   { border-color: var(--error);   background: #fff1f2; }
.mc-btn.selected-wrong .mc-letter   { background: var(--error); }
.mc-btn.show-correct     { border-color: var(--success); background: #f0fdf4; }
.mc-btn.show-correct .mc-letter     { background: var(--success); }
.mc-btn:disabled { cursor: default; }

/* MC Edit (edit.html) */
.q-type-badge { font-size: 0.72rem; background: #e0e7ff; color: var(--primary); padding: 2px 8px; border-radius: 20px; margin-right: 6px; }
.mc-edit-options { background: #fffbeb; border: 1px solid #fde68a; border-radius: 10px; padding: 12px 14px; margin: 8px 0; }
.mc-edit-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.mc-edit-row:last-child { margin-bottom: 0; }
.mc-edit-letter { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: white; display:inline-flex; align-items:center; justify-content:center; font-weight:700; font-size:0.85rem; flex-shrink:0; }
.mc-opt-input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; font-family: 'Tajawal', sans-serif; font-size: 0.9rem; }
.mc-radio-wrap { display: flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 0.82rem; color: var(--success); cursor: pointer; }

/* ══════════════════════════════════════════════
   ═══════════ QUIZ PAGE ═══════════
══════════════════════════════════════════════ */
.quiz-page { max-width: 680px; margin: 0 auto; padding: 0; display: flex; flex-direction: column; }

/* Top bar */
.quiz-topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.quiz-topbar a { color: var(--primary); text-decoration: none; font-size: 1.3rem; }
.quiz-title { font-weight: 700; font-size: 1rem; flex: 1; }
.quiz-counter { font-size: 0.88rem; color: var(--text-muted); white-space: nowrap; direction: ltr; unicode-bidi: isolate; }

/* Progress bar (quiz) */
.quiz-progress-wrap {
  background: white;
  padding: 0 20px 14px;
  border-bottom: 1px solid var(--border);
}
.quiz-progress-bar {
  height: 6px;
  background: var(--border);
  border-radius: 99px;
  overflow: hidden;
  direction: ltr;
}
.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #7c3aed);
  border-radius: 99px;
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

/* Question area */
.quiz-body { flex: 1; padding: 32px 20px 24px; display: flex; flex-direction: column; }

.question-card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px 28px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 1px solid var(--border);
  min-height: 320px;
}
.question-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 99px;
  margin-bottom: 18px;
  width: fit-content;
}
.question-text {
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.8;
  color: var(--text);
  flex: 1;
  margin-bottom: 28px;
}

/* Answer buttons */
.answer-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.ans-btn {
  padding: 18px 10px;
  border: 2.5px solid transparent;
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 1.3rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.ans-btn-true {
  background: var(--success-light);
  color: var(--success);
  border-color: #86efac;
}
.ans-btn-true:hover:not(:disabled) {
  background: var(--success);
  color: white;
  border-color: var(--success);
  transform: scale(1.02);
}
.ans-btn-false {
  background: var(--error-light);
  color: var(--error);
  border-color: #fca5a5;
}
.ans-btn-false:hover:not(:disabled) {
  background: var(--error);
  color: white;
  border-color: var(--error);
  transform: scale(1.02);
}
.ans-btn:disabled { cursor: not-allowed; opacity: 0.6; transform: none !important; }
.ans-btn.selected-correct { background: var(--success) !important; color: white !important; border-color: var(--success) !important; }
.ans-btn.selected-wrong   { background: var(--error)   !important; color: white !important; border-color: var(--error)   !important; }
.ans-btn.show-correct     { background: var(--success) !important; color: white !important; border-color: var(--success) !important; opacity: 1 !important; }

/* Feedback banner */
.feedback-banner {
  margin-top: 18px;
  padding: 16px 20px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 1.05rem;
  display: none;
  align-items: center;
  gap: 10px;
}
.feedback-banner.visible { display: flex; }
.feedback-banner.correct { background: var(--success-light); color: var(--success); border: 1.5px solid #86efac; }
.feedback-banner.wrong   { background: var(--error-light);   color: var(--error);   border: 1.5px solid #fca5a5; }
.feedback-banner .fb-icon { font-size: 1.5rem; flex-shrink: 0; }

/* Next button */
.next-btn-wrap { padding: 16px 20px 32px; }
.btn-next {
  width: 100%;
  padding: 15px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  display: none;
  transition: all 0.2s;
}
.btn-next.visible { display: block; }
.btn-next:hover { background: var(--primary-dark); }

/* ══════════════════════════════════════════════
   Results Screen
══════════════════════════════════════════════ */
.results-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  padding: 32px 20px 48px;
  text-align: center;
}
.results-screen.visible { display: flex; }

.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  margin-bottom: 20px;
  box-shadow: 0 8px 32px rgba(79,70,229,0.35);
  animation: pop-in 0.5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes pop-in { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.score-number { font-size: 2.8rem; font-weight: 900; line-height: 1; }
.score-label  { font-size: 0.85rem; opacity: 0.85; }

.score-emoji { font-size: 2.5rem; margin-bottom: 8px; }
.score-title { font-size: 1.5rem; font-weight: 800; color: var(--text); margin-bottom: 6px; }
.score-sub   { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 28px; }

.results-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 400px;
  margin-bottom: 28px;
}
.stat-box {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.stat-box strong { display: block; font-size: 1.5rem; font-weight: 800; color: var(--text); }

.results-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 360px;
}
.results-actions .btn { width: 100%; justify-content: center; font-size: 1rem; padding: 14px; }
.btn-green  { background: var(--success); color: white; }
.btn-green:hover { background: #15803d; }

/* Wrong Answers Review */
.review-section {
  width: 100%;
  max-width: 680px;
  padding: 0 20px 48px;
  display: none;
}
.review-section.visible { display: block; }
.review-section h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; color: var(--error); }
.review-item {
  background: white;
  border: 1.5px solid #fca5a5;
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-bottom: 12px;
  text-align: right;
}
.review-item .ri-text { font-size: 1rem; color: var(--text); margin-bottom: 10px; line-height: 1.7; }
.review-item .ri-answers { display: flex; gap: 12px; font-size: 0.88rem; }
.ri-your { color: var(--error); font-weight: 700; }
.ri-correct { color: var(--success); font-weight: 700; }

/* ══════════════════════════════════════════════
   Loading / Error Screens
══════════════════════════════════════════════ */
.full-screen-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 32px;
  text-align: center;
  gap: 12px;
}
.full-screen-msg .msg-icon { font-size: 3rem; }
.full-screen-msg h2 { font-size: 1.3rem; font-weight: 700; }
.full-screen-msg p { color: var(--text-muted); font-size: 0.95rem; }
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════
   Review Quiz Mode
══════════════════════════════════════════════ */
.review-mode-badge {
  background: var(--error);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 99px;
}

/* ══════════════════════════════════════════════
   Copy Link
══════════════════════════════════════════════ */
.link-copied {
  font-size: 0.78rem;
  color: var(--success);
  font-weight: 700;
  opacity: 0;
  transition: opacity 0.3s;
}
.link-copied.show { opacity: 1; }

/* ══════════════════════════════════════════════
   Animations
══════════════════════════════════════════════ */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}
@keyframes bounce-in {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}
.animate-shake   { animation: shake 0.4s ease; }
.animate-bounce  { animation: bounce-in 0.35s ease; }

/* ══════════════════════════════════════════════
   Keyboard hint
══════════════════════════════════════════════ */
.kb-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}

/* ══════════════════════════════════════════════
   Note / Explanation (after answer)
══════════════════════════════════════════════ */
.note-box {
  background: #fffbeb;
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 0.92rem;
  color: #92400e;
  display: none;
  line-height: 1.7;
  text-align: right;
}
.note-box.visible { display: block; }
.note-box .note-label {
  font-weight: 700;
  display: block;
  margin-bottom: 4px;
  color: #78350f;
}
.ri-note {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.82rem;
  color: #92400e;
  margin-top: 8px;
}

/* ══════════════════════════════════════════════
   Edit Buttons (admin mode)
══════════════════════════════════════════════ */
.btn-edit {
  background: #f0fdf4;
  color: var(--success);
  border: 1.5px solid #86efac;
  font-size: 0.85rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s;
}
.btn-edit:hover { background: var(--success); color: white; border-color: var(--success); }

/* Hide/show quiz toggle */
.btn-toggle-hidden {
  background: #f8fafc;
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  font-size: 0.95rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  transition: all 0.2s;
}
.btn-toggle-hidden:hover { background: #fef9c3; border-color: #fbbf24; color: #92400e; }
.hidden-badge {
  display: inline-block;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  margin-right: 6px;
  vertical-align: middle;
}
.quiz-item.is-hidden {
  opacity: 0.55;
  border-style: dashed;
}

/* ══════════════════════════════════════════════
   Edit Page
══════════════════════════════════════════════ */
.edit-page-wrap {
  max-width: 820px;
  margin: 0 auto;
  padding: 0;
}
.edit-topbar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.edit-topbar a { color: var(--primary); text-decoration: none; font-size: 1.3rem; }
.edit-topbar .edit-title { font-weight: 700; font-size: 1rem; flex: 1; }
.edit-body { padding: 24px 20px 80px; }

.q-edit-item {
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: border-color 0.2s;
}
.q-edit-item:hover { border-color: #a5b4fc; }
.q-edit-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.q-num {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: 99px;
  white-space: nowrap;
  flex-shrink: 0;
}
.q-edit-text {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.97rem;
  color: var(--text);
  background: #fafafa;
  direction: rtl;
  resize: vertical;
  min-height: 60px;
  outline: none;
  transition: border-color 0.2s;
}
.q-edit-text:focus { border-color: var(--primary); background: white; }

.q-edit-note {
  width: 100%;
  padding: 8px 14px;
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.88rem;
  color: #92400e;
  background: #fffbeb;
  direction: rtl;
  resize: vertical;
  min-height: 48px;
  outline: none;
  transition: border-color 0.2s;
  margin-top: 10px;
}
.q-edit-note:focus { border-color: var(--warning); }
.q-edit-note::placeholder { color: #d97706; opacity: 0.7; }

.answer-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}
.answer-toggle-wrap label { font-size: 0.85rem; color: var(--text-muted); font-weight: 600; }
.answer-toggle {
  display: flex;
  border: 1.5px solid var(--border);
  border-radius: 99px;
  overflow: hidden;
}
.answer-toggle button {
  padding: 5px 16px;
  border: none;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  background: white;
  color: var(--text-muted);
}
.answer-toggle button.active-true  { background: var(--success); color: white; }
.answer-toggle button.active-false { background: var(--error);   color: white; }

.edit-save-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
  z-index: 20;
}
.edit-save-bar .save-hint { font-size: 0.85rem; color: var(--text-muted); }
.edit-search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}
.edit-search-bar input {
  flex: 1;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.95rem;
  direction: rtl;
  outline: none;
  background: white;
}
.edit-search-bar input:focus { border-color: var(--primary); }
.edit-count-badge {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ══════════════════════════════════════════════
   Mobile Responsive — Quiz Page
══════════════════════════════════════════════ */
@media (max-width: 600px) {
  /* Prevent horizontal overflow */
  .quiz-page { width: 100%; max-width: 100%; }
  .quiz-topbar { left: 0; right: 0; width: 100%; box-sizing: border-box; }

  /* Quiz topbar */
  .quiz-topbar { padding: 10px 14px; gap: 8px; }
  .quiz-topbar a { font-size: 1.1rem; }
  .quiz-title { font-size: 0.85rem; }
  .quiz-counter { font-size: 0.8rem; }
  .quiz-progress-wrap { padding: 0 14px 10px; }

  /* Question card */
  .quiz-body { padding: 16px 12px 12px; }
  .question-card { padding: 20px 16px; min-height: 0; }
  .question-badge { font-size: 0.72rem; padding: 3px 10px; margin-bottom: 12px; }
  .question-text { font-size: 1.05rem; margin-bottom: 20px; line-height: 1.7; }

  /* Answer buttons */
  .answer-btns { gap: 10px; }
  .ans-btn { padding: 14px 8px; font-size: 1.1rem; }

  /* MC options */
  .mc-btn { padding: 12px 10px; font-size: 0.92rem; }
  .mc-letter { width: 28px; height: 28px; font-size: 0.8rem; }

  /* Feedback & note */
  .feedback-banner { font-size: 0.9rem; padding: 12px 14px; margin-top: 12px; }
  .note-box { font-size: 0.88rem; padding: 10px 14px; }
  .kb-hint { font-size: 0.75rem; }

  /* Next button */
  .next-btn-wrap { padding: 12px 12px 16px; }
  .btn-next { padding: 13px; font-size: 1rem; }

  /* Results screen */
  .results-screen { padding: 24px 16px 32px; }
  .score-circle { width: 130px; height: 130px; }
  .score-number { font-size: 2rem; }
  .results-stats { gap: 10px; }
  .stat-box { padding: 12px 16px; }
  .results-actions { gap: 10px; }
  .results-actions .btn { padding: 12px 20px; font-size: 0.95rem; }

  /* Review section */
  .review-item { padding: 14px 14px; }
}
