/* ==============================
   QUIZ PLATFORM — Mobile-First CSS
   ============================== */

:root {
  --primary:        #6366F1;
  --primary-hover:  #4F46E5;
  --primary-light:  #EEF2FF;
  --primary-dark:   #3730A3;

  --success:        #22C55E;
  --success-light:  #DCFCE7;
  --success-dark:   #16A34A;

  --danger:         #EF4444;
  --danger-light:   #FEE2E2;
  --danger-dark:    #DC2626;

  --warning:        #F59E0B;
  --warning-light:  #FEF3C7;
  --warning-dark:   #D97706;

  --info:           #3B82F6;
  --info-light:     #EFF6FF;

  --bg:             #F1F5F9;
  --surface:        #FFFFFF;
  --border:         #E2E8F0;
  --border-dark:    #CBD5E1;

  --text:           #0F172A;
  --text-muted:     #64748B;
  --text-light:     #94A3B8;

  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:  0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.12);

  --radius-sm:  8px;
  --radius:     12px;
  --radius-lg:  16px;
  --radius-xl:  24px;
  --radius-full:9999px;

  --nav-h:        56px;
  --bottom-nav-h: 62px;
  --transition:   all .15s ease;
}

/* ---- RESET ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button { font-family: inherit; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dark); border-radius: 2px; }

/* ==============================
   LAYOUT
   ============================== */
.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
  width: 100%;
}
.main-wrap {
  padding-top: var(--nav-h);
  padding-bottom: calc(var(--bottom-nav-h) + 8px);
  min-height: 100vh;
}
@media (min-width: 768px) {
  .main-wrap { padding-bottom: 32px; }
}

/* ==============================
   TOP NAVIGATION
   ============================== */
.top-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  align-items: center;
}
.top-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
}
.brand-logo {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}
.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-avatar {
  width: 34px; height: 34px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-weight: 700;
  font-size: 0.9rem;
}
.nav-link-btn {
  padding: 7px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  transition: var(--transition);
  border: none;
  cursor: pointer;
  background: none;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 5px;
}
.nav-link-btn:hover { background: var(--bg); color: var(--text); }
.nav-link-btn.primary {
  background: var(--primary);
  color: white;
}
.nav-link-btn.primary:hover { background: var(--primary-hover); }

/* Desktop nav links */
.desktop-nav { display: none; }
@media (min-width: 768px) {
  .desktop-nav {
    display: flex;
    align-items: center;
    gap: 4px;
  }
  .desktop-nav a {
    padding: 7px 12px;
    border-radius: 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    transition: var(--transition);
    display: flex; align-items: center; gap: 5px;
  }
  .desktop-nav a:hover, .desktop-nav a.active {
    background: var(--primary-light);
    color: var(--primary);
  }
}

/* ==============================
   BOTTOM NAVIGATION (mobile)
   ============================== */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottom-nav-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  z-index: 100;
  padding: 0 4px;
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  padding: 6px 4px;
  border-radius: 10px;
  transition: var(--transition);
  text-decoration: none;
}
.bottom-nav a:hover, .bottom-nav a.active {
  color: var(--primary);
  background: var(--primary-light);
}
.bottom-nav a .bnav-icon {
  font-size: 20px;
  line-height: 1;
}
.bottom-nav a.add-btn {
  background: var(--primary);
  color: white !important;
  border-radius: 14px;
  width: 52px;
  height: 44px;
  flex: none;
  margin: 0 8px;
}
.bottom-nav a.add-btn:hover { background: var(--primary-hover); }
@media (min-width: 768px) {
  .bottom-nav { display: none; }
}

/* ==============================
   MESSAGES / ALERTS
   ============================== */
.messages-wrap {
  padding: 8px 0 0;
}
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 8px;
  position: relative;
}
.alert-success { background: var(--success-light); color: var(--success-dark); border: 1px solid #86EFAC; }
.alert-error,
.alert-danger   { background: var(--danger-light);  color: var(--danger-dark);  border: 1px solid #FCA5A5; }
.alert-warning  { background: var(--warning-light); color: var(--warning-dark); border: 1px solid #FCD34D; }
.alert-info     { background: var(--info-light);    color: #1D4ED8;             border: 1px solid #93C5FD; }
.alert-close {
  position: absolute; top: 10px; right: 10px;
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: 0.6; font-size: 14px; padding: 2px;
}

/* ==============================
   CARDS
   ============================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-body { padding: 16px; }
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.card + .card { margin-top: 10px; }

/* ==============================
   BUTTONS
   ============================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.925rem;
  font-weight: 500;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  min-height: 44px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary   { background: var(--primary);   color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: white; }

.btn-success   { background: var(--success);   color: white; border-color: var(--success); }
.btn-success:hover { background: var(--success-dark); border-color: var(--success-dark); color: white; }

.btn-danger    { background: var(--danger);    color: white; border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-dark); border-color: var(--danger-dark); color: white; }

.btn-warning   { background: var(--warning);   color: white; border-color: var(--warning); }

.btn-outline {
  background: transparent;
  border-color: var(--border-dark);
  color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }

.btn-ghost {
  background: transparent; border-color: transparent; color: var(--text-muted);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm  { padding: 6px 12px; font-size: 0.825rem; min-height: 34px; border-radius: 8px; }
.btn-lg  { padding: 14px 24px; font-size: 1rem; border-radius: var(--radius-lg); min-height: 52px; }
.btn-xl  { padding: 16px 28px; font-size: 1.1rem; border-radius: var(--radius-xl); min-height: 58px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 40px; height: 40px; padding: 0;
  border-radius: 10px;
}
.btn-icon.sm { width: 32px; height: 32px; border-radius: 8px; }

/* ==============================
   BADGES
   ============================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  gap: 4px;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: var(--success-dark); }
.badge-danger  { background: var(--danger-light);  color: var(--danger-dark); }
.badge-warning { background: var(--warning-light); color: var(--warning-dark); }
.badge-gray    { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

/* ==============================
   FORMS
   ============================== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-control {
  display: block;
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px; /* prevents iOS auto-zoom */
  color: var(--text);
  background: var(--surface);
  transition: var(--transition);
  outline: none;
  -webkit-appearance: none;
  font-family: inherit;
  line-height: 1.4;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}
.form-control::placeholder { color: var(--text-light); }
.form-control:disabled { background: var(--bg); opacity: .7; }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748B' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 36px;
  cursor: pointer;
}
.form-hint  { font-size: 0.78rem; color: var(--text-muted); margin-top: 5px; }
.form-error { font-size: 0.78rem; color: var(--danger);      margin-top: 5px; display: block; }
.form-control.is-invalid { border-color: var(--danger); }
.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.form-section-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Toggle switch */
.toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.toggle-wrap:last-child { border-bottom: none; padding-bottom: 0; }
.toggle-wrap label { font-size: 0.9rem; color: var(--text); cursor: pointer; }
.toggle-wrap .hint { font-size: 0.78rem; color: var(--text-muted); }
input[type="checkbox"].toggle {
  width: 40px; height: 22px;
  appearance: none; -webkit-appearance: none;
  background: var(--border-dark);
  border-radius: 11px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  flex-shrink: 0;
}
input[type="checkbox"].toggle::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
}
input[type="checkbox"].toggle:checked { background: var(--primary); }
input[type="checkbox"].toggle:checked::after { left: 21px; }

/* Radio mode select */
.mode-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.mode-card {
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 12px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.mode-card.selected, .mode-card:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.mode-card input { display: none; }
.mode-card-icon { font-size: 1.8rem; margin-bottom: 6px; display: block; }
.mode-card-title { font-weight: 600; font-size: 0.9rem; }
.mode-card-desc  { font-size: 0.75rem; color: var(--text-muted); margin-top: 3px; }

/* ==============================
   STATS
   ============================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  display: block;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ==============================
   PAGE HEADER
   ============================== */
.page-header {
  padding: 18px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}
.page-back {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--radius);
  transition: var(--transition);
  margin-bottom: 12px;
}
.page-back:hover { background: var(--bg); color: var(--text); }

/* ==============================
   TEST CARDS
   ============================== */
.test-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 8px;
  overflow: hidden;
  transition: box-shadow .15s;
}
.test-card:hover { box-shadow: var(--shadow-md); }
.test-card-inner {
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.test-card-icon {
  width: 40px; height: 40px;
  background: var(--primary-light);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  font-size: 18px;
  flex-shrink: 0;
}
.test-card-content { flex: 1; min-width: 0; }
.test-card-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.test-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.meta-dot { color: var(--border-dark); }
.test-card-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.test-card-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Folder item */
.folder-row {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  overflow: hidden;
  transition: box-shadow .15s;
}
.folder-row:hover { box-shadow: var(--shadow-md); }
.folder-row-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
}
.folder-icon {
  width: 36px; height: 36px;
  background: var(--warning-light);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.folder-name { font-weight: 500; font-size: 0.9rem; }
.folder-count { font-size: 0.78rem; color: var(--text-muted); }
.folder-actions {
  padding-right: 10px;
  display: flex;
  gap: 4px;
}

/* ==============================
   BREADCRUMBS
   ============================== */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 8px 0;
  flex-wrap: wrap;
}
.breadcrumbs a { color: var(--primary); }
.breadcrumbs .sep { color: var(--border-dark); }

/* ==============================
   QUIZ MODE
   ============================== */
.quiz-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.quiz-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.quiz-progress-text {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}
.progress-bar {
  height: 4px;
  background: var(--border);
  overflow: hidden;
  flex: 1;
  border-radius: 2px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.4s ease;
  border-radius: 2px;
}
.timer-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.95rem;
  font-weight: 700;
  border: 1.5px solid var(--primary);
  transition: var(--transition);
  min-width: 70px;
  justify-content: center;
}
.timer-pill.warn { background: var(--warning-light); color: var(--warning-dark); border-color: var(--warning); }
.timer-pill.danger {
  background: var(--danger-light); color: var(--danger-dark); border-color: var(--danger);
  animation: timerPulse .6s infinite;
}
@keyframes timerPulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.05); }
}
.quiz-body {
  flex: 1;
  padding: 20px 16px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.q-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.q-credit-badge {
  background: var(--warning-light);
  color: var(--warning-dark);
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
}
.q-text {
  font-size: 1.05rem;
  line-height: 1.65;
  font-weight: 500;
  margin-bottom: 22px;
  color: var(--text);
}
.q-image {
  display: block;
  max-width: 100%;
  max-height: 360px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid var(--border);
}
.answer-image {
  display: block;
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  margin-top: 8px;
}
.img-preview {
  display: block;
  max-width: 100%;
  max-height: 160px;
  border-radius: var(--radius);
  margin-top: 8px;
  border: 1px solid var(--border);
}
.answer-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 10px;
  text-align: left;
  min-height: 54px;
}
.answer-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}
.answer-btn.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}
.answer-btn.correct { border-color: var(--success); background: var(--success-light); color: var(--success-dark); }
.answer-btn.wrong   { border-color: var(--danger);  background: var(--danger-light);  color: var(--danger-dark);  }
.answer-letter {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--bg);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.answer-btn.selected .answer-letter { background: var(--primary); color: white; }
.answer-btn.correct  .answer-letter { background: var(--success); color: white; }
.answer-btn.wrong    .answer-letter { background: var(--danger);  color: white; }
.answer-text { line-height: 1.4; padding-top: 3px; }
.quiz-footer {
  padding: 12px 16px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

/* ==============================
   EXAM MODE
   ============================== */
.exam-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.exam-topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.exam-topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
}
.exam-timer-big {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}
.exam-timer-big.warn    { color: var(--warning-dark); }
.exam-timer-big.danger  { color: var(--danger-dark); animation: timerPulse .6s infinite; }
.exam-progress-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 500;
}
.exam-body {
  flex: 1;
  padding: 12px 16px 20px;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
}
.exam-question-block {
  display: none;
}
.exam-question-block.active {
  display: block;
  animation: fadeSlide .2s ease;
}
@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.exam-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 10px 16px;
  position: sticky;
  bottom: 0;
  z-index: 40;
}
.exam-footer-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 720px;
  margin: 0 auto;
}
/* Question sidebar / drawer — shared by quiz + exam mode */
.q-grid-toggle {
  background: none;
  border: none;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}
.q-sidebar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.q-sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.35;
}
.q-sidebar-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
  margin-bottom: 14px;
}
.q-sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 1rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  flex-shrink: 0;
}
.q-sidebar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 14px;
}
.q-sidebar-legend span { display: flex; align-items: center; gap: 5px; }
.q-legend-dot {
  width: 10px; height: 10px;
  border-radius: 3px;
  display: inline-block;
  border: 1.5px solid var(--border);
  background: var(--surface);
}
.q-legend-dot.answered { background: var(--primary); border-color: var(--primary); }
.q-legend-dot.correct  { background: var(--success); border-color: var(--success); }
.q-legend-dot.wrong    { background: var(--danger);  border-color: var(--danger); }
.q-legend-dot.skipped  { background: var(--warning); border-color: var(--warning); }

.q-grid-panel { display: none; }

.q-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-top: 8px;
}
.q-dot {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--transition);
  text-decoration: none;
}
.q-dot.answered { background: var(--primary); border-color: var(--primary); color: white; }
.q-dot.correct  { background: var(--success); border-color: var(--success); color: white; }
.q-dot.wrong    { background: var(--danger);  border-color: var(--danger);  color: white; }
.q-dot.skipped  { background: var(--warning); border-color: var(--warning); color: white; }
.q-dot.current  { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99,102,241,.35); }

/* Mobile: question grid opens as a bottom sheet */
@media (max-width: 767px) {
  .q-grid-panel.open {
    display: block;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    max-height: 72vh;
    overflow-y: auto;
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -8px 28px rgba(15, 23, 42, .16);
    padding: 18px 16px 24px;
    z-index: 70;
  }
  .q-sidebar-close { display: block; }
}

/* Desktop: persistent left sidebar */
@media (min-width: 768px) {
  .quiz-layout, .exam-layout { flex-direction: row; align-items: stretch; }
  .quiz-main, .exam-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
  }
  .q-sidebar {
    display: flex !important;
    flex-direction: column;
    width: 280px;
    flex-shrink: 0;
    max-height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    overflow-y: auto;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 20px;
  }
  .q-sidebar-close { display: none; }
  .q-grid-toggle { display: none; }
}

/* ==============================
   RESULT PAGE
   ============================== */
.result-hero {
  text-align: center;
  padding: 28px 16px;
}
.score-ring {
  width: 130px; height: 130px;
  border-radius: 50%;
  margin: 0 auto 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 5px solid;
}
.score-ring.passed { border-color: var(--success); background: var(--success-light); color: var(--success-dark); }
.score-ring.failed { border-color: var(--danger);  background: var(--danger-light);  color: var(--danger-dark); }
.score-ring .score-num  { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.score-ring .score-unit { font-size: 0.75rem; font-weight: 500; opacity: .8; }
.result-verdict {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.result-verdict.passed { color: var(--success-dark); }
.result-verdict.failed { color: var(--danger-dark); }
.result-meta { font-size: 0.875rem; color: var(--text-muted); }
.result-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  padding: 0 16px 16px;
}
@media (min-width: 480px) {
  .result-stats { grid-template-columns: repeat(4, 1fr); }
}
.result-breakdown {
  padding: 0 16px 80px;
}
.result-item {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.result-item:last-child { border-bottom: none; }
.result-status-icon {
  width: 26px; height: 26px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  margin-top: 1px;
}
.result-status-icon.correct { background: var(--success-light); color: var(--success-dark); }
.result-status-icon.wrong   { background: var(--danger-light);  color: var(--danger-dark); }
.result-status-icon.skipped { background: var(--bg); color: var(--text-light); border: 1px solid var(--border); }
.result-q-num  { font-size: 0.72rem; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; }
.result-q-text { font-size: 0.875rem; font-weight: 500; margin-bottom: 5px; }
.result-answer { font-size: 0.8rem; }

/* ==============================
   HERO SECTION
   ============================== */
.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #7C3AED 100%);
  color: white;
  padding: 52px 0 44px;
  text-align: center;
}
.hero h1  { font-size: 2rem; font-weight: 800; margin-bottom: 10px; line-height: 1.2; }
.hero p   { font-size: 1rem; opacity: .9; margin-bottom: 24px; }
@media (min-width: 480px) {
  .hero h1 { font-size: 2.4rem; }
}
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.btn-white {
  background: white; color: var(--primary);
  border-color: white;
}
.btn-white:hover { background: #F8F7FF; color: var(--primary-hover); border-color: #F8F7FF; }
.btn-outline-white {
  background: transparent; color: white; border-color: rgba(255,255,255,.5);
}
.btn-outline-white:hover { background: rgba(255,255,255,.1); }

/* ==============================
   AUTH PAGES
   ============================== */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.auth-header {
  padding: 28px 28px 0;
  text-align: center;
}
.auth-logo {
  width: 52px; height: 52px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 26px;
  font-weight: 800;
  margin: 0 auto 16px;
}
.auth-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.auth-sub   { font-size: 0.875rem; color: var(--text-muted); margin-bottom: 24px; }
.auth-body  { padding: 20px 28px 28px; }
.auth-footer {
  padding: 16px 28px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}
.auth-footer a { color: var(--primary); font-weight: 500; }

/* ==============================
   EMPTY STATE
   ============================== */
.empty-state {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-muted);
}
.empty-icon  { font-size: 3.5rem; margin-bottom: 14px; opacity: .4; }
.empty-title { font-size: 1rem; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.empty-desc  { font-size: 0.875rem; margin-bottom: 20px; }

/* ==============================
   DIVIDER
   ============================== */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.section-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ==============================
   DROPDOWN
   ============================== */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 160px;
  z-index: 200;
  overflow: hidden;
  display: none;
}
.dropdown-menu.open { display: block; animation: fadeSlide .15s ease; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--text);
  transition: background .1s;
  cursor: pointer;
  width: 100%;
  background: none;
  border: none;
  font-family: inherit;
}
.dropdown-item:hover { background: var(--bg); }
.dropdown-item.danger { color: var(--danger-dark); }
.dropdown-item.danger:hover { background: var(--danger-light); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ==============================
   UTILITIES
   ============================== */
.d-flex      { display: flex; }
.flex-col    { flex-direction: column; }
.items-center{ align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.flex-1      { flex: 1; min-width: 0; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-wrap   { flex-wrap: wrap; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.p-4  { padding: 16px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.py-2 { padding-top: 8px;  padding-bottom: 8px; }
.w-full { width: 100%; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }
.text-muted   { color: var(--text-muted) !important; }
.text-primary  { color: var(--primary) !important; }
.text-success  { color: var(--success-dark) !important; }
.text-danger   { color: var(--danger-dark) !important; }
.text-warning  { color: var(--warning-dark) !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.fs-sm  { font-size: 0.8rem; }
.fs-xs  { font-size: 0.72rem; }
.hidden { display: none !important; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
code, pre {
  font-family: 'Courier New', monospace;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.825rem;
}
pre {
  padding: 12px;
  overflow-x: auto;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
code { padding: 2px 5px; }

/* ==============================
   PROFILE
   ============================== */

/* Nav avatar image */
.nav-avatar-img {
  width: 100%; height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* Cover gradient banner */
.profile-cover {
  height: 180px;
  background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 55%, #06B6D4 100%);
}

/* Wrapper that pulls card up over cover */
.profile-card-wrap {
  max-width: 680px;
  margin: -60px auto 0;
  padding: 0 1rem 3rem;
}

/* Main white card */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: visible;
}

/* Top section: avatar + action button */
.profile-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 1.5rem 0;
  margin-top: -44px;
}

/* Avatar */
.profile-avatar-box {
  flex-shrink: 0;
}
.profile-av-img {
  width: 100px; height: 100px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-md);
  display: block;
}
.profile-av-placeholder {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  font-size: 2.6rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid var(--surface);
  box-shadow: var(--shadow-md);
  user-select: none;
}

/* Action buttons */
.profile-card-actions {
  padding-bottom: .5rem;
}
.pf-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .45rem 1.1rem;
  border-radius: var(--radius-full);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.pf-btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.pf-btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.pf-btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border-dark);
}
.pf-btn-outline:hover { background: var(--bg); }
.pf-btn-following {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-dark);
}
.pf-btn-following:hover { border-color: var(--danger); color: var(--danger); }

/* Name, bio, since */
.profile-card-meta {
  padding: 1rem 1.5rem 1.25rem;
}
.pf-name {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 .15rem;
  line-height: 1.2;
}
.pf-uname {
  font-size: .85rem;
  color: var(--text-muted);
  margin: 0 0 .75rem;
}
.pf-bio {
  font-size: .92rem;
  color: var(--text);
  line-height: 1.55;
  margin: 0 0 .6rem;
  white-space: pre-line;
}
.pf-bio-add {
  font-size: .85rem;
  color: var(--primary);
  display: block;
  margin-bottom: .6rem;
}
.pf-since {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .78rem;
  color: var(--text-muted);
}

/* Stats row */
.pf-stats {
  display: flex;
  align-items: center;
  border-top: 1px solid var(--border);
}
.pf-stat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem .5rem;
  cursor: default;
  transition: background .15s;
}
.pf-stat:hover { background: var(--bg); }
.pf-stat-n {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}
.pf-stat-l {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .2rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 500;
}
.pf-stat-div {
  width: 1px;
  height: 36px;
  background: var(--border);
  flex-shrink: 0;
}

/* Clickable stat link */
a.pf-stat-link {
  text-decoration: none;
  color: inherit;
}
a.pf-stat-link:hover { background: var(--bg); }
a.pf-stat-link:hover .pf-stat-n { color: var(--primary); }

/* ==============================
   USER CARDS (search / lists)
   ============================== */

/* Page title */
.page-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 1.25rem;
}

/* User card list */
.ucard-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

/* Individual user card */
.ucard {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
}
.ucard:hover { box-shadow: var(--shadow-md); }

.ucard-avatar-link { flex-shrink: 0; }
.ucard-av-img {
  width: 52px; height: 52px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
  display: block;
}
.ucard-av-placeholder {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.ucard-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.ucard-name {
  font-weight: 700;
  font-size: .95rem;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ucard-name:hover { color: var(--primary); }
.ucard-username {
  font-size: .78rem;
  color: var(--text-muted);
}
.ucard-bio {
  font-size: .82rem;
  color: var(--text-muted);
  margin: .15rem 0 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ucard-meta {
  font-size: .75rem;
  color: var(--text-light);
  margin-top: .1rem;
}

/* User list page header */
.ulist-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.ulist-back {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  transition: color .15s;
}
.ulist-back:hover { color: var(--primary); }
.ulist-tabs {
  display: flex;
  gap: .25rem;
  background: var(--bg);
  padding: .25rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
}
.ulist-tab {
  padding: .35rem .9rem;
  border-radius: var(--radius-full);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: all .15s;
}
.ulist-tab.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 700;
  box-shadow: var(--shadow-sm);
}
.ulist-tab:hover:not(.active) { color: var(--text); }

/* Search form */
.search-form {
  display: flex;
  gap: .75rem;
  margin-bottom: 1.5rem;
  align-items: stretch;
}
.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: .875rem;
  color: var(--text-muted);
  pointer-events: none;
  flex-shrink: 0;
}
.search-input {
  width: 100%;
  padding: .65rem 2.5rem .65rem 2.75rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.search-input:focus { border-color: var(--primary); }
.search-clear {
  position: absolute;
  right: .875rem;
  color: var(--text-muted);
  font-size: .85rem;
  text-decoration: none;
  padding: .25rem;
  line-height: 1;
}
.search-clear:hover { color: var(--danger); }
.search-count {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

@media (max-width: 520px) {
  .ucard { padding: .875rem 1rem; }
  .ucard-av-img, .ucard-av-placeholder { width: 44px; height: 44px; font-size: 1.2rem; }
  .search-form { flex-direction: column; }
  .ulist-header { gap: .75rem; }
}

/* ---- Profile Edit Form ---- */
.avatar-upload-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .75rem;
  padding: 1.25rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  text-align: center;
  transition: border-color .15s;
}
.avatar-upload-wrap:hover { border-color: var(--primary); }
.avatar-preview {
  width: 96px; height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--primary-light);
}
.avatar-preview-placeholder {
  width: 96px; height: 96px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff;
  font-size: 2.5rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}
.avatar-upload-label {
  cursor: pointer;
  color: var(--primary);
  font-size: .875rem;
  font-weight: 600;
}
input[type="file"]#id_avatar { display: none; }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Responsive */
@media (max-width: 520px) {
  .profile-cover { height: 130px; }
  .profile-card-wrap { margin-top: -50px; }
  .profile-card-top { margin-top: -38px; }
  .profile-av-img,
  .profile-av-placeholder { width: 80px; height: 80px; font-size: 2rem; }
  .pf-name { font-size: 1.15rem; }
  .pf-stat-n { font-size: 1.1rem; }
  .form-row-2 { grid-template-columns: 1fr; }
}

/* ==============================
   ANIMATIONS
   ============================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn .25s ease; }

/* ==============================
   MOBILE-ONLY / DESKTOP-ONLY
   ============================== */
.mobile-only { display: block; }
.desktop-only { display: none; }
@media (min-width: 768px) {
  .mobile-only  { display: none !important; }
  .desktop-only { display: block; }
}

/* Explanation shown after answering in quiz mode */
.q-explanation {
  margin-top: 14px; padding: 12px 14px; border-radius: 12px;
  background: var(--bg, #F1F5F9); border: 1px solid var(--border, #E2E8F0);
  border-left: 4px solid var(--info, #3B82F6);
  font-size: .9rem; line-height: 1.55;
}
.q-explanation.ok  { border-left-color: var(--success, #22C55E); }
.q-explanation.bad { border-left-color: var(--danger, #EF4444); }
.q-explanation-title { font-weight: 700; margin-bottom: 4px; }
/* JS fills the body with textContent after an AJAX answer - keep line breaks */
.q-explanation-body { white-space: pre-line; }
