/**
 * CAMPUS FORMULA – Custom CSS
 * ============================
 * Brand: Primary #fabf2c | Dark #212529
 * Tenant can override --cf-accent via PHP-injected <style> in header.php
 *
 * Structure:
 *   1. CSS Variables & Reset
 *   2. Typography
 *   3. Layout (wrapper, sidebar, main)
 *   4. Navbar
 *   5. Sidebar
 *   6. Cards & UI Components
 *   7. Skeleton Loaders
 *   8. Dashboard
 *   9. Practice Module
 *  10. Mock Exam Module
 *  11. Daily Dose
 *  12. Leaderboard
 *  13. Results
 *  14. Notifications
 *  15. Badges & Pills
 *  16. Utilities
 *  17. Responsive (Mobile-first, all breakpoints)
 */

/* ═══════════════════════════════════════════════════════════════════════════
   1. CSS Variables & Reset
   ═══════════════════════════════════════════════════════════════════════════ */
:root {
  --cf-accent: #fabf2c;
  --cf-accent-rgb: 250, 191, 44;
  --cf-dark: #212529;
  --cf-dark-2: #2c3136;
  --cf-dark-3: #343a40;
  --cf-sidebar-w: 260px;
  --cf-navbar-h: 62px;
  --cf-radius: 12px;
  --cf-radius-lg: 18px;
  --cf-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  --cf-shadow-md: 0 4px 24px rgba(0, 0, 0, 0.12);
  --cf-transition: 0.2s ease;
  --cf-font: "Plus Jakarta Sans", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  /* Prevent font size inflation on mobile */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--cf-font);
  background: #f4f5f7;
  color: var(--cf-dark);
  font-size: 0.9rem;
  line-height: 1.6;
  overflow-x: hidden;
  /* Allow momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

/* Prevent layout shift when SweetAlert opens */
body.swal2-shown {
  padding-right: 0 !important;
}

/* ═══════════════════════════════════════════════════════════════════════════
   2. Typography
   ═══════════════════════════════════════════════════════════════════════════ */
.fw-600 {
  font-weight: 600 !important;
}
.fw-700 {
  font-weight: 700 !important;
}
.fw-800 {
  font-weight: 800 !important;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: 700;
}

.cf-page-title {
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  font-weight: 800;
  color: var(--cf-dark);
  margin: 0;
}

.cf-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--cf-dark);
  margin-bottom: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   3. Layout
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.cf-layout {
  display: flex;
  flex: 1;
  padding-top: var(--cf-navbar-h);
}

.cf-main-content {
  flex: 1;
  margin-left: var(--cf-sidebar-w);
  padding: 1.5rem;
  min-height: calc(100vh - var(--cf-navbar-h));
  transition: margin-left var(--cf-transition);
  /* Prevent horizontal overflow from children */
  min-width: 0;
  overflow-x: hidden;
}

/* ═══════════════════════════════════════════════════════════════════════════
   4. Navbar
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-navbar {
  background: var(--cf-dark);
  height: var(--cf-navbar-h);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1040;
  border-bottom: 3px solid var(--cf-accent);
  padding: 0 1rem;
}

.cf-brand-text {
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--cf-accent);
  letter-spacing: -0.5px;
  /* Truncate on very small screens */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.cf-logo {
  border-radius: 6px;
  object-fit: contain;
  /* Prevent logo from breaking layout */
  max-height: 40px;
  width: auto;
}

.cf-icon-btn {
  color: rgba(255, 255, 255, 0.8);
  padding: 0.4rem;
  position: relative;
  line-height: 1;
  /* Minimum touch target (44×44px) */
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cf-icon-btn:hover {
  color: var(--cf-accent);
}

.cf-notif-dot {
  width: 8px;
  height: 8px;
  background: #ef4444;
  border-radius: 50%;
  position: absolute;
  top: 4px;
  right: 4px;
  border: 2px solid var(--cf-dark);
}

.cf-xp-badge,
.cf-streak-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--cf-accent);
  background: rgba(var(--cf-accent-rgb), 0.12);
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  border: 1px solid rgba(var(--cf-accent-rgb), 0.25);
  white-space: nowrap;
}
.cf-streak-badge {
  color: #f97316;
  background: rgba(249, 115, 22, 0.1);
  border-color: rgba(249, 115, 22, 0.2);
}

/* Avatar */
.cf-avatar-btn {
  padding: 0;
  border: none;
  line-height: 1;
  color: rgba(255, 255, 255, 0.8);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cf-avatar-btn::after {
  display: none;
}
.cf-avatar-btn:hover {
  color: var(--cf-accent);
}

.cf-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(var(--cf-accent-rgb), 0.4);
}
.cf-avatar-initials {
  background: var(--cf-accent);
  color: var(--cf-dark);
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Dropdown */
.cf-dropdown {
  border: none;
  border-radius: var(--cf-radius);
  box-shadow: var(--cf-shadow-md);
  min-width: 220px;
  /* Keep dropdown within viewport on mobile */
  max-width: calc(100vw - 2rem);
}
.cf-dropdown .dropdown-item {
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  /* Minimum touch target */
  min-height: 44px;
  display: flex;
  align-items: center;
}
.cf-dropdown .dropdown-item:hover {
  background: rgba(var(--cf-accent-rgb), 0.1);
}

/* Sidebar toggle */
.cf-sidebar-toggle {
  color: rgba(255, 255, 255, 0.8);
  padding: 0.3rem;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cf-sidebar-toggle:hover {
  color: var(--cf-accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   5. Sidebar
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-sidebar {
  width: var(--cf-sidebar-w);
  background: var(--cf-dark);
  position: fixed;
  top: var(--cf-navbar-h);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 1030;
  display: flex;
  flex-direction: column;
  transition: transform var(--cf-transition);
  scrollbar-width: thin;
  scrollbar-color: rgba(var(--cf-accent-rgb), 0.2) transparent;
  /* Momentum scrolling on iOS */
  -webkit-overflow-scrolling: touch;
}

.cf-sidebar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.25rem 1rem 1rem;
}

.cf-sidebar-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(var(--cf-accent-rgb), 0.4);
  flex-shrink: 0;
}

.cf-sidebar-user-info {
  flex: 1;
  overflow: hidden;
  color: #fff;
}

.cf-plan-badge {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.6);
}

.cf-xp-strip {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.8rem;
}

.cf-sidebar-divider {
  border-color: rgba(255, 255, 255, 0.08);
  margin: 0 1rem;
}

.cf-sidebar-nav {
  flex: 1;
  padding: 0.5rem 0;
}

.cf-sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  color: rgba(255, 255, 255, 0.65);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.875rem;
  border-left: 3px solid transparent;
  transition: all var(--cf-transition);
  position: relative;
  margin: 1px 0.5rem;
  border-radius: var(--cf-radius);
  /* Touch target */
  min-height: 44px;
}
.cf-sidebar-link:hover {
  color: var(--cf-accent);
  background: rgba(var(--cf-accent-rgb), 0.08);
}
.cf-sidebar-link.active {
  color: var(--cf-dark);
  background: var(--cf-accent);
  font-weight: 700;
  border-left-color: transparent;
}
.cf-sidebar-link.active .cf-sidebar-icon {
  color: var(--cf-dark);
}
.cf-sidebar-link.locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.cf-sidebar-icon {
  font-size: 1.05rem;
  flex-shrink: 0;
}

.cf-nav-badge {
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
  margin-left: auto;
}

.cf-sidebar-footer {
  padding: 0.75rem 0.5rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Overlay for mobile */
.cf-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1029;
  /* Prevent overlay tap from propagating */
  -webkit-tap-highlight-color: transparent;
}
.cf-sidebar-overlay.show {
  display: block;
}

/* Offcanvas (notifications) */
.cf-offcanvas {
  width: 350px !important;
  border-left: 3px solid var(--cf-accent);
  /* Full width on small screens */
  max-width: 100vw;
}
.cf-notif-item {
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  transition: background var(--cf-transition);
}
.cf-notif-item.unread {
  background: rgba(var(--cf-accent-rgb), 0.08);
  border-color: rgba(var(--cf-accent-rgb), 0.25);
}

/* ═══════════════════════════════════════════════════════════════════════════
   6. Cards & UI Components
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-card {
  background: #fff;
  border: none;
  border-radius: var(--cf-radius-lg);
  box-shadow: var(--cf-shadow);
  overflow: hidden;
}

.cf-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Primary Button */
.btn-cf-primary {
  background: var(--cf-accent);
  color: var(--cf-dark);
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.4rem;
  transition: all var(--cf-transition);
  /* Touch target */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* Prevent text wrapping inside button */
  white-space: nowrap;
}
.btn-cf-primary:hover {
  background: color-mix(in srgb, var(--cf-accent) 85%, #000);
  color: var(--cf-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(var(--cf-accent-rgb), 0.4);
}
.btn-cf-primary:active {
  transform: none;
}

/* Outline Button */
.btn-cf-outline {
  background: transparent;
  color: var(--cf-accent);
  border: 2px solid var(--cf-accent);
  font-weight: 700;
  border-radius: 10px;
  padding: 0.5rem 1.2rem;
  transition: all var(--cf-transition);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.btn-cf-outline:hover {
  background: var(--cf-accent);
  color: var(--cf-dark);
}

/* Form controls */
.cf-select,
.cf-input {
  border: 1.5px solid #dee2e6;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  font-family: var(--cf-font);
  font-size: 0.875rem;
  transition: border-color var(--cf-transition);
  width: 100%;
  background: #fff;
  /* Minimum touch target */
  min-height: 44px;
  /* Prevent zoom on iOS (font-size must be >= 16px to avoid zoom) */
  font-size: max(16px, 0.875rem);
  -webkit-appearance: none;
  appearance: none;
}
.cf-select:focus,
.cf-input:focus {
  outline: none;
  border-color: var(--cf-accent);
  box-shadow: 0 0 0 3px rgba(var(--cf-accent-rgb), 0.15);
}

/* Badge */
.cf-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}
.cf-badge-accent {
  background: rgba(var(--cf-accent-rgb), 0.15);
  color: color-mix(in srgb, var(--cf-accent) 70%, #000);
}
.cf-badge-green {
  background: rgba(22, 163, 74, 0.1);
  color: #15803d;
}
.cf-badge-red {
  background: rgba(220, 38, 38, 0.1);
  color: #dc2626;
}
.cf-badge-blue {
  background: rgba(37, 99, 235, 0.1);
  color: #1d4ed8;
}

/* ═══════════════════════════════════════════════════════════════════════════
   7. Skeleton Loaders
   ═══════════════════════════════════════════════════════════════════════════ */
@keyframes cfShimmer {
  0% {
    background-position: -600px 0;
  }
  100% {
    background-position: 600px 0;
  }
}

.cf-skeleton {
  background: linear-gradient(90deg, #e8e8e8 25%, #f5f5f5 50%, #e8e8e8 75%);
  background-size: 600px 100%;
  animation: cfShimmer 1.4s infinite linear;
  border-radius: 8px;
}

.cf-skeleton-text {
  height: 14px;
  width: 100%;
  margin-bottom: 8px;
}
.cf-skeleton-title {
  height: 22px;
  width: 60%;
  margin-bottom: 12px;
}
.cf-skeleton-btn {
  height: 44px;
  width: 120px;
  border-radius: 10px;
}
.cf-skeleton-card {
  height: 140px;
  border-radius: var(--cf-radius-lg);
}
.cf-skeleton-notif {
  height: 72px;
  border-radius: var(--cf-radius);
}
.cf-skeleton-option {
  height: 52px;
  border-radius: 10px;
  margin-bottom: 10px;
}
.cf-skeleton-q {
  height: 100px;
  border-radius: 12px;
  margin-bottom: 16px;
}

.cf-skeleton-question-block {
  background: #fff;
  border-radius: var(--cf-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--cf-shadow);
  margin-bottom: 1.25rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   8. Dashboard
   ═══════════════════════════════════════════════════════════════════════════ */

/* Welcome Banner */
.cf-welcome-banner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.cf-welcome-greeting {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--cf-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

/* XP Level Card */
.cf-xp-level-card {
  background: #fff;
  border-radius: var(--cf-radius-lg);
  padding: 1rem 1.25rem;
  min-width: 200px;
  max-width: 100%;
  box-shadow: var(--cf-shadow);
  flex-shrink: 0;
}
.cf-level-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.cf-xp-bar-bg {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.cf-xp-bar-fill {
  height: 100%;
  background: var(--cf-accent);
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Stat Cards */
.cf-stat-card {
  background: #fff;
  border-radius: var(--cf-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--cf-shadow);
  height: 100%;
}
.cf-stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 0.75rem;
}
.cf-stat-value {
  font-size: clamp(1.3rem, 4vw, 1.6rem);
  font-weight: 800;
  color: var(--cf-dark);
  line-height: 1;
  margin-bottom: 0.2rem;
}
.cf-stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--cf-dark);
}
.cf-stat-sub {
  font-size: 0.72rem;
  color: #9ca3af;
}

/* Quick Actions */
.cf-quick-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.cf-quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  background: #fff;
  border: 1.5px solid #e5e7eb;
  border-radius: var(--cf-radius-lg);
  padding: 1rem 0.75rem;
  min-width: 80px;
  flex: 1;
  text-decoration: none;
  color: var(--cf-dark);
  font-size: 0.78rem;
  font-weight: 700;
  transition: all var(--cf-transition);
  position: relative;
  /* Minimum touch target */
  min-height: 80px;
}
.cf-quick-btn i {
  font-size: 1.4rem;
  color: var(--cf-accent);
}
.cf-quick-btn:hover {
  border-color: var(--cf-accent);
  background: rgba(var(--cf-accent-rgb), 0.05);
  transform: translateY(-2px);
  box-shadow: var(--cf-shadow);
  color: var(--cf-dark);
}
.cf-quick-btn-dose i {
  color: #f97316;
}
.cf-quick-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 20px;
  background: #ef4444;
  color: #fff;
}
.cf-quick-badge-done {
  background: #22c55e !important;
}
.cf-quick-badge:empty {
  display: none;
}

/* Result rows */
.cf-result-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

/* Daily Dose CTA Card */
.cf-dose-cta-card {
  border-radius: var(--cf-radius-lg);
  padding: 1.25rem 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
}
.cf-dose-pending {
  background: linear-gradient(135deg, var(--cf-dark) 0%, #2c3136 100%);
  color: #fff;
}
.cf-dose-done {
  background: linear-gradient(135deg, #166534 0%, #14532d 100%);
  color: #fff;
}

/* Link button */
.cf-btn-link {
  color: var(--cf-accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.cf-btn-link:hover {
  background: rgba(var(--cf-accent-rgb), 0.1);
  color: var(--cf-accent);
}

/* ═══════════════════════════════════════════════════════════════════════════
   9. Practice Module
   ═══════════════════════════════════════════════════════════════════════════ */

/* Filter bar */
.cf-filter-bar {
  background: #fff;
  border-radius: var(--cf-radius-lg);
  padding: 1.25rem;
  box-shadow: var(--cf-shadow);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.cf-filter-bar label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.3rem;
  display: block;
}
.cf-filter-group {
  flex: 1;
  min-width: 160px;
}

/* Question card */
.cf-question-card {
  background: #fff;
  border-radius: var(--cf-radius-lg);
  padding: 1.5rem;
  box-shadow: var(--cf-shadow);
  margin-bottom: 1.25rem;
  border-left: 4px solid transparent;
  transition:
    border-color var(--cf-transition),
    box-shadow var(--cf-transition);
  /* Prevent content overflow */
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.cf-question-card.answered-correct {
  border-left-color: #22c55e;
}
.cf-question-card.answered-wrong {
  border-left-color: #ef4444;
}
.cf-question-card.answered-skip {
  border-left-color: #94a3b8;
}

.cf-q-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--cf-accent);
  background: rgba(var(--cf-accent-rgb), 0.1);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  display: inline-block;
  margin-bottom: 0.75rem;
}

.cf-q-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--cf-dark);
  line-height: 1.7;
  margin-bottom: 1rem;
  /* Break long words/URLs */
  overflow-wrap: break-word;
  word-break: break-word;
}

.cf-q-image {
  max-width: 100%;
  height: auto;
  max-height: 300px;
  border-radius: 10px;
  margin-bottom: 1rem;
  object-fit: contain;
  display: block;
}

/* Options */
.cf-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border: 1.5px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: all var(--cf-transition);
  user-select: none;
  -webkit-user-select: none;
  /* Touch target */
  min-height: 52px;
  /* Active state for touch */
  -webkit-tap-highlight-color: transparent;
}
.cf-option:hover {
  border-color: var(--cf-accent);
  background: rgba(var(--cf-accent-rgb), 0.04);
}
.cf-option.selected {
  border-color: var(--cf-accent);
  background: rgba(var(--cf-accent-rgb), 0.1);
}
.cf-option.correct {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.08);
}
.cf-option.wrong {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.08);
}
.cf-option.disabled {
  pointer-events: none;
}

.cf-option-letter {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #f3f4f6;
  color: #374151;
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--cf-transition);
}
.cf-option.selected .cf-option-letter {
  background: var(--cf-accent);
  color: var(--cf-dark);
}
.cf-option.correct .cf-option-letter {
  background: #22c55e;
  color: #fff;
}
.cf-option.wrong .cf-option-letter {
  background: #ef4444;
  color: #fff;
}

.cf-option-text {
  font-size: 0.875rem;
  flex: 1;
  color: var(--cf-dark);
  /* Wrap text properly */
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}

/* Explanation box */
.cf-explanation {
  background: rgba(var(--cf-accent-rgb), 0.06);
  border: 1px solid rgba(var(--cf-accent-rgb), 0.2);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  margin-top: 1rem;
  font-size: 0.875rem;
  display: none;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cf-explanation.show {
  display: block;
}
.cf-explanation strong {
  color: var(--cf-dark);
}

/* Progress bar */
.cf-practice-progress {
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.cf-practice-progress-fill {
  height: 100%;
  background: var(--cf-accent);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Score summary card */
.cf-score-card {
  background: var(--cf-dark);
  color: #fff;
  border-radius: var(--cf-radius-lg);
  padding: 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.cf-score-card::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 160px;
  height: 160px;
  background: rgba(var(--cf-accent-rgb), 0.15);
  border-radius: 50%;
}
.cf-score-big {
  font-size: clamp(2.2rem, 8vw, 3.5rem);
  font-weight: 800;
  color: var(--cf-accent);
  line-height: 1;
}

/* Pagination nav */
.cf-pagination {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.cf-page-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid #dee2e6;
  background: #fff;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--cf-transition);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Comfortable touch target */
  min-width: 36px;
}
.cf-page-btn:hover,
.cf-page-btn.active {
  background: var(--cf-accent);
  border-color: var(--cf-accent);
  color: var(--cf-dark);
}

/* ═══════════════════════════════════════════════════════════════════════════
   10. Mock Exam Module
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-mock-card {
  background: #fff;
  border-radius: var(--cf-radius-lg);
  box-shadow: var(--cf-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  transition:
    transform var(--cf-transition),
    box-shadow var(--cf-transition);
}
.cf-mock-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--cf-shadow-md);
}
.cf-mock-card-header {
  padding: 1rem 1.1rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  background: linear-gradient(135deg, #fafafa 0%, #fff 100%);
}
.cf-mock-card-body {
  padding: 0.75rem 1.1rem;
  flex: 1;
}
.cf-mock-card-footer {
  padding: 0.75rem 1.1rem 1rem;
  border-top: 1px solid #f0f0f0;
}
.cf-mock-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #6b7280;
}
.cf-mock-meta span {
  display: flex;
  align-items: center;
  gap: 0.2rem;
}

.cf-timer-bar {
  background: var(--cf-dark);
  color: var(--cf-accent);
  font-size: clamp(0.95rem, 3vw, 1.2rem);
  font-weight: 800;
  padding: 0.5rem 1.25rem;
  border-radius: var(--cf-radius);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cf-timer-bar.danger {
  color: #ef4444;
  animation: pulse 0.8s infinite;
}
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

.cf-subject-tab-nav {
  gap: 0.5rem;
  flex-wrap: wrap;
}
.cf-subject-tab {
  padding: 0.4rem 1rem;
  border-radius: 20px;
  border: 1.5px solid #dee2e6;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  background: #fff;
  transition: all var(--cf-transition);
  /* Touch target */
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.cf-subject-tab.active {
  background: var(--cf-accent);
  border-color: var(--cf-accent);
  color: var(--cf-dark);
}

/* ═══════════════════════════════════════════════════════════════════════════
   11. Daily Dose
   ═══════════════════════════════════════════════════════════════════════════ */

.cf-network-banner {
  background: #1e3a5f;
  color: #93c5fd;
  border-radius: var(--cf-radius);
  padding: 0.65rem 1.1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  display: flex;
  align-items: center;
  border-left: 4px solid #3b82f6;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.cf-dose-complete-banner {
  background: linear-gradient(135deg, var(--cf-dark) 0%, #1a2035 100%);
  color: #fff;
  padding: 2.5rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.cf-dose-complete-banner::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: rgba(var(--cf-accent-rgb), 0.08);
  border-radius: 50%;
}

.cf-dose-session-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.cf-dose-xp-chip {
  background: rgba(var(--cf-accent-rgb), 0.15);
  color: color-mix(in srgb, var(--cf-accent) 70%, #000);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  border: 1px solid rgba(var(--cf-accent-rgb), 0.3);
}
.cf-dose-xp-chip-show {
  animation: xpPop 0.4s ease;
}
@keyframes xpPop {
  0% {
    opacity: 0;
    transform: scale(0.6);
  }
  70% {
    transform: scale(1.15);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

.cf-xp-pulse {
  animation: xpPulse 0.5s ease;
}
@keyframes xpPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.12);
    box-shadow: 0 0 12px rgba(var(--cf-accent-rgb), 0.5);
  }
}

.cf-sync-indicator {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 20px;
  padding: 0.3rem 0.85rem;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  box-shadow: var(--cf-shadow);
  z-index: 500;
  transition: opacity 0.3s;
  /* Keep above nav on mobile */
  bottom: max(1.25rem, env(safe-area-inset-bottom, 1.25rem));
}

.cf-spin {
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

.cf-dose-header {
  background: linear-gradient(135deg, var(--cf-dark) 60%, var(--cf-dark-2));
  color: #fff;
  border-radius: var(--cf-radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}
.cf-dose-header::after {
  content: "⚡";
  position: absolute;
  right: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 4rem;
  opacity: 0.08;
  /* Hide on very small screens to prevent overlap */
  pointer-events: none;
}

.cf-dose-xp {
  background: rgba(var(--cf-accent-rgb), 0.15);
  color: var(--cf-accent);
  border-radius: var(--cf-radius);
  padding: 0.4rem 1rem;
  font-weight: 700;
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   12. Leaderboard
   ═══════════════════════════════════════════════════════════════════════════ */

.cf-lb-tabs {
  border-bottom: 2px solid #e5e7eb;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.cf-lb-tab {
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 0.65rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #6b7280;
  cursor: pointer;
  transition: all var(--cf-transition);
  border-radius: 0;
  /* Touch target */
  min-height: 44px;
  white-space: nowrap;
}
.cf-lb-tab:hover {
  color: var(--cf-accent);
}
.cf-lb-tab.active {
  color: var(--cf-dark);
  border-bottom-color: var(--cf-accent);
}

.cf-my-rank-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  background: #fff;
  border-radius: var(--cf-radius);
  padding: 0.5rem 1rem;
  box-shadow: var(--cf-shadow);
  margin-left: 0.5rem;
}
.cf-my-rank-num {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--cf-accent);
  line-height: 1;
}

/* Podium */
.cf-podium-wrap {
  padding: 1.5rem 1.5rem 0.5rem;
  background: linear-gradient(
    180deg,
    rgba(var(--cf-accent-rgb), 0.06) 0%,
    transparent 100%
  );
  border-bottom: 1px solid #f0f0f0;
}
.cf-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 1rem;
}
.cf-podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  padding-bottom: 1rem;
  animation: podiumRise 0.5s ease both;
  /* Prevent overflow on small screens */
  max-width: 33%;
}
@keyframes podiumRise {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.cf-podium-1 {
  animation-delay: 0.1s;
}
.cf-podium-2 {
  animation-delay: 0.2s;
}
.cf-podium-3 {
  animation-delay: 0.3s;
}

.cf-podium-slot::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 4px 4px 0 0;
  width: 80px;
}
.cf-podium-1::after {
  height: 60px;
  background: var(--cf-accent);
  opacity: 0.15;
}
.cf-podium-2::after {
  height: 42px;
  background: #c0c0c0;
  opacity: 0.2;
}
.cf-podium-3::after {
  height: 28px;
  background: #cd7f32;
  opacity: 0.2;
}

.cf-podium-medal {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
}
.cf-podium-avatar {
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid #fff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  margin-bottom: 0.5rem;
  /* Responsive size */
  width: clamp(44px, 10vw, 64px);
  height: clamp(44px, 10vw, 64px);
}
.cf-podium-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--cf-dark);
  max-width: 90px;
  word-break: break-word;
  line-height: 1.3;
}

/* Row list */
.cf-leaderboard-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--cf-radius);
  transition: background var(--cf-transition);
}
.cf-leaderboard-row:hover {
  background: #f8f9fa;
}
.cf-leaderboard-row.me {
  background: rgba(var(--cf-accent-rgb), 0.08);
  border: 1.5px solid rgba(var(--cf-accent-rgb), 0.25);
}

.cf-rank-badge {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cf-rank-1 {
  background: #ffd700;
  color: #000;
}
.cf-rank-2 {
  background: #c0c0c0;
  color: #000;
}
.cf-rank-3 {
  background: #cd7f32;
  color: #fff;
}
.cf-rank-n {
  background: #f3f4f6;
  color: #374151;
}

/* ═══════════════════════════════════════════════════════════════════════════
   13. Results
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-result-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f0f0f0;
  transition: background var(--cf-transition);
  gap: 0.5rem;
  flex-wrap: wrap;
}
.cf-result-row:last-child {
  border-bottom: none;
}
.cf-result-row:hover {
  background: #fafafa;
}

.cf-score-pill {
  padding: 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}
.cf-score-high {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}
.cf-score-mid {
  background: rgba(234, 179, 8, 0.12);
  color: #854d0e;
}
.cf-score-low {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.cf-expand-btn {
  width: 30px;
  height: 30px;
  border: 1.5px solid #dee2e6;
  border-radius: 8px;
  background: #fff;
  color: #6b7280;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--cf-transition);
}
.cf-expand-btn:hover {
  border-color: var(--cf-accent);
  color: var(--cf-accent);
}

.cf-result-detail {
  background: #f8f9fa;
  border-top: 1px solid #f0f0f0;
  border-bottom: 1px solid #f0f0f0;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.cf-detail-table {
  padding: 0.75rem 1rem;
}
.cf-detail-row {
  display: flex;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  margin-bottom: 0.4rem;
  border-left: 3px solid transparent;
}
.cf-detail-row.correct {
  background: rgba(34, 197, 94, 0.05);
  border-left-color: #22c55e;
}
.cf-detail-row.wrong {
  background: rgba(239, 68, 68, 0.05);
  border-left-color: #ef4444;
}

.cf-detail-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e5e7eb;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}
.cf-detail-q {
  color: var(--cf-dark);
  line-height: 1.5;
  overflow-wrap: break-word;
  word-break: break-word;
  min-width: 0;
}
.cf-detail-exp {
  background: rgba(var(--cf-accent-rgb), 0.06);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  color: #6b7280;
  font-style: italic;
}

/* ═══════════════════════════════════════════════════════════════════════════
   14. Notifications
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-notif-card {
  border-radius: var(--cf-radius);
  padding: 0.85rem 1rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  margin-bottom: 0.6rem;
  transition: all var(--cf-transition);
}
.cf-notif-card.unread {
  background: rgba(var(--cf-accent-rgb), 0.05);
  border-color: rgba(var(--cf-accent-rgb), 0.2);
}

/* Tab bar */
.cf-notif-tabs {
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  padding: 0.4rem;
  background: #fff;
  border-radius: var(--cf-radius-lg);
  box-shadow: var(--cf-shadow);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cf-notif-tabs::-webkit-scrollbar {
  display: none;
}

.cf-notif-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: #6b7280;
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--cf-font);
  cursor: pointer;
  transition: all var(--cf-transition);
  white-space: nowrap;
  min-height: 44px;
  flex-shrink: 0;
}
.cf-notif-tab:hover {
  background: #f3f4f6;
  color: var(--cf-dark);
}
.cf-notif-tab.active {
  background: var(--cf-accent);
  color: var(--cf-dark);
}
.cf-notif-tab-count {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  padding: 0 5px;
  font-size: 0.68rem;
  font-weight: 800;
  min-width: 18px;
  text-align: center;
  line-height: 1.5;
}
.cf-notif-tab.active .cf-notif-tab-count {
  background: rgba(0, 0, 0, 0.15);
}
.unread-tab-badge {
  background: #ef4444 !important;
  color: #fff !important;
}

/* Notification user card */
.cf-notif-user-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem 1.1rem;
  background: #fff;
  border-radius: var(--cf-radius-lg);
  border: 1px solid #e5e7eb;
  margin-bottom: 0.6rem;
  cursor: pointer;
  transition: all var(--cf-transition);
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.cf-notif-user-card:hover {
  border-color: rgba(var(--cf-accent-rgb), 0.3);
  box-shadow: var(--cf-shadow);
  transform: translateY(-1px);
}
.cf-notif-user-card.unread {
  background: rgba(var(--cf-accent-rgb), 0.04);
  border-color: rgba(var(--cf-accent-rgb), 0.2);
}
.cf-notif-user-card.unread::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 4px;
  height: 60%;
  background: var(--cf-accent);
  border-radius: 0 3px 3px 0;
}

.cf-notif-user-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  flex-shrink: 0;
}
.cf-notif-user-body {
  flex: 1;
  min-width: 0;
}
.cf-notif-user-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--cf-dark);
  margin-bottom: 0.25rem;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cf-notif-user-preview {
  font-size: 0.82rem;
  color: #6b7280;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cf-notif-user-detail {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.7;
  margin-top: 0.35rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: 8px;
  border-left: 3px solid var(--cf-accent);
  animation: fadeIn 0.2s ease;
  overflow-wrap: break-word;
  word-break: break-word;
}
.cf-notif-user-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: #9ca3af;
  flex-wrap: wrap;
}
.cf-notif-user-chevron {
  color: #9ca3af;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
  transition: transform 0.2s;
}

.cf-unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cf-accent);
  flex-shrink: 0;
  margin-top: 3px;
}

.cf-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ef4444;
  color: #fff;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.5rem;
  vertical-align: middle;
  margin-left: 0.4rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   15. Badges & Pills
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-difficulty-easy {
  color: #15803d;
  font-weight: 700;
  font-size: 0.75rem;
}
.cf-difficulty-medium {
  color: #b45309;
  font-weight: 700;
  font-size: 0.75rem;
}
.cf-difficulty-hard {
  color: #b91c1c;
  font-weight: 700;
  font-size: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Profile Page
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-avatar-edit-btn {
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--cf-accent);
  color: var(--cf-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  cursor: pointer;
  border: 2px solid #fff;
  transition: transform 0.2s;
}
.cf-avatar-edit-btn:hover {
  transform: scale(1.1);
}

.cf-subject-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.8rem;
  border-radius: 20px;
  border: 1.5px solid #dee2e6;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  color: #6b7280;
  user-select: none;
  -webkit-user-select: none;
  min-height: 44px;
}
.cf-subject-toggle input {
  display: none;
}
.cf-subject-toggle:hover {
  border-color: var(--cf-accent);
  color: var(--cf-dark);
}
.cf-subject-toggle.checked {
  background: rgba(var(--cf-accent-rgb), 0.12);
  border-color: var(--cf-accent);
  color: color-mix(in srgb, var(--cf-accent) 60%, #000);
}

/* ═══════════════════════════════════════════════════════════════════════════
   Resources Hub
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-resource-card {
  background: #fff;
  border-radius: var(--cf-radius-lg);
  border: 1px solid #e5e7eb;
  padding: 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  transition: all var(--cf-transition);
  height: 100%;
}
.cf-resource-card:hover {
  border-color: rgba(var(--cf-accent-rgb), 0.3);
  box-shadow: var(--cf-shadow);
  transform: translateY(-2px);
}
.cf-resource-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.cf-resource-info {
  flex: 1;
  min-width: 0;
}
.cf-resource-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--cf-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.3rem;
}
.cf-resource-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.72rem;
  color: #9ca3af;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════════════════════
   16. Utilities
   ═══════════════════════════════════════════════════════════════════════════ */
.cf-divider {
  border: none;
  border-top: 1px solid #f0f0f0;
  margin: 1rem 0;
}

.cf-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #9ca3af;
}
.cf-empty-state i {
  font-size: 2.5rem;
  margin-bottom: 1rem;
  display: block;
}

.cf-loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid rgba(var(--cf-accent-rgb), 0.3);
  border-top-color: var(--cf-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Make images and tables in question text responsive */
.cf-q-text img,
.cf-q-text table {
  max-width: 100%;
  height: auto;
}

/* Tables responsive wrapper (add via JS if needed) */
.cf-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Prevent text selection during exam */
.no-select {
  user-select: none;
  -webkit-user-select: none;
}

/* Plan table */
.cf-plan-table td,
.cf-plan-table th {
  vertical-align: middle;
}

/* Hover row */
.cf-hover-row {
  transition: background var(--cf-transition);
}
.cf-hover-row:hover {
  background: #f8f9fa;
}

/* ═══════════════════════════════════════════════════════════════════════════
   17. Responsive – Mobile-first, comprehensive breakpoints
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Large tablets / small desktops (< 1200px) ── */
@media (max-width: 1199.98px) {
  :root {
    --cf-sidebar-w: 240px;
  }
}

/* ── Tablets (< 992px) – sidebar becomes offcanvas ── */
@media (max-width: 991.98px) {
  .cf-sidebar {
    transform: translateX(-100%);
    /* Full sidebar width but not wider than screen */
    width: min(var(--cf-sidebar-w), 85vw);
  }
  .cf-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .cf-main-content {
    margin-left: 0;
    padding: 1rem;
  }

  .cf-filter-bar {
    flex-direction: column;
  }
  .cf-filter-group {
    min-width: 100%;
    width: 100%;
  }

  /* Quick actions: 2 per row minimum */
  .cf-quick-btn {
    min-width: calc(50% - 0.375rem);
    max-width: calc(50% - 0.375rem);
    flex: 0 0 calc(50% - 0.375rem);
  }

  /* Stack welcome banner properly */
  .cf-welcome-banner {
    flex-direction: column;
  }
  .cf-xp-level-card {
    width: 100%;
    min-width: unset;
  }

  /* Leaderboard: scroll tabs horizontally */
  .cf-lb-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .cf-lb-tabs::-webkit-scrollbar {
    display: none;
  }
  .cf-lb-tab {
    flex-shrink: 0;
  }

  /* Mock card grid: 2 columns */
  .cf-offcanvas {
    width: min(350px, 90vw) !important;
  }
}

/* ── Mobile (< 768px) ── */
@media (max-width: 767.98px) {
  /* Tighten main padding */
  .cf-main-content {
    padding: 0.875rem;
  }

  /* Navbar: hide XP/streak badges to save space */
  .cf-xp-badge,
  .cf-streak-badge {
    display: none;
  }

  /* Cards: slightly less padding */
  .cf-card-header {
    padding: 0.875rem 1rem;
  }

  /* Score card */
  .cf-score-card {
    padding: 1.5rem 1rem;
  }

  /* Question card */
  .cf-question-card {
    padding: 1rem;
  }

  /* Options: full width comfortable touch targets */
  .cf-option {
    padding: 0.85rem 0.875rem;
  }

  /* Quick actions: flexible 2-column grid */
  .cf-quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.6rem;
  }
  .cf-quick-btn {
    min-width: unset;
    max-width: unset;
    flex: unset;
  }

  /* Stat cards: full-width stacked */
  .cf-stat-card {
    padding: 1rem;
  }

  /* Podium: slightly smaller on mobile */
  .cf-podium {
    gap: 0.5rem;
  }
  .cf-podium-medal {
    font-size: 1.4rem;
  }
  .cf-podium-name {
    font-size: 0.72rem;
    max-width: 70px;
  }

  /* Leaderboard rows */
  .cf-leaderboard-row {
    gap: 0.6rem;
    padding: 0.65rem 0.75rem;
  }

  /* Result rows: allow wrap */
  .cf-result-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  /* Daily dose header: hide decorative emoji */
  .cf-dose-header::after {
    display: none;
  }
  .cf-dose-complete-banner {
    padding: 1.75rem 1.25rem;
  }

  /* Filter bar */
  .cf-filter-bar {
    padding: 1rem;
  }

  /* Notif offcanvas: full width */
  .cf-offcanvas {
    width: 100vw !important;
  }

  /* Timer: compact */
  .cf-timer-bar {
    padding: 0.4rem 0.875rem;
  }

  /* Subject tabs: horizontal scroll */
  .cf-subject-tab-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .cf-subject-tab-nav::-webkit-scrollbar {
    display: none;
  }
  .cf-subject-tab {
    flex-shrink: 0;
  }

  /* Sync indicator: keep above keyboard */
  .cf-sync-indicator {
    bottom: max(0.75rem, env(safe-area-inset-bottom, 0.75rem));
    right: 0.75rem;
  }

  /* Notification user cards: tighter */
  .cf-notif-user-card {
    padding: 0.875rem 0.875rem;
    gap: 0.75rem;
  }
  .cf-notif-user-icon {
    width: 38px;
    height: 38px;
    font-size: 1rem;
  }
}

/* ── Small mobile (< 576px) ── */
@media (max-width: 575.98px) {
  :root {
    --cf-navbar-h: 58px;
    --cf-radius: 10px;
    --cf-radius-lg: 14px;
  }

  .cf-main-content {
    padding: 0.75rem;
  }

  /* Page title */
  .cf-page-title {
    font-size: 1.1rem;
  }

  /* Brand text: shorter on very small screens */
  .cf-brand-text {
    font-size: 1rem;
    max-width: 110px;
  }

  /* Score */
  .cf-score-big {
    font-size: 2.5rem;
  }

  /* Question card: minimal padding */
  .cf-question-card {
    padding: 0.875rem;
  }

  /* Option letter: slightly smaller */
  .cf-option-letter {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 0.78rem;
  }

  /* Quick actions: 3 columns on very small screens */
  .cf-quick-actions {
    grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
    gap: 0.5rem;
  }
  .cf-quick-btn {
    padding: 0.75rem 0.5rem;
    font-size: 0.72rem;
    min-height: 72px;
  }
  .cf-quick-btn i {
    font-size: 1.2rem;
  }

  /* Timer bar */
  .cf-timer-bar {
    font-size: 0.95rem;
    padding: 0.4rem 0.75rem;
  }

  /* Dose header */
  .cf-dose-header {
    padding: 1.1rem;
  }

  /* Podium: very compact */
  .cf-podium {
    gap: 0.25rem;
  }
  .cf-podium-slot {
    max-width: 30%;
  }
  .cf-podium-slot::after {
    width: 60px;
  }
  .cf-podium-name {
    font-size: 0.68rem;
    max-width: 60px;
  }

  /* Rank badge: smaller */
  .cf-rank-badge {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  /* Leaderboard rows */
  .cf-leaderboard-row {
    padding: 0.6rem 0.5rem;
    gap: 0.5rem;
  }

  /* Mock card */
  .cf-mock-card-header,
  .cf-mock-card-body,
  .cf-mock-card-footer {
    padding: 0.875rem;
  }

  /* Skeleton btn: proper touch target */
  .cf-skeleton-btn {
    height: 44px;
  }

  /* Notif card: compact */
  .cf-notif-user-card {
    padding: 0.75rem;
    gap: 0.6rem;
  }
  .cf-notif-user-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }
  .cf-notif-user-title {
    font-size: 0.85rem;
  }
  .cf-notif-user-preview {
    font-size: 0.78rem;
  }

  /* Score summary paddings */
  .cf-score-card {
    padding: 1.25rem 0.875rem;
  }

  /* Pagination: wrap comfortably */
  .cf-pagination {
    gap: 0.35rem;
  }
  .cf-page-btn {
    width: 34px;
    height: 34px;
  }

  /* Card header: stacked */
  .cf-card-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* ── Extra small (< 400px) – extreme mobile ── */
@media (max-width: 399.98px) {
  :root {
    --cf-radius: 8px;
    --cf-radius-lg: 12px;
  }

  .cf-main-content {
    padding: 0.6rem;
  }

  .cf-question-card {
    padding: 0.75rem;
    border-radius: var(--cf-radius-lg);
  }
  .cf-q-text {
    font-size: 0.875rem;
  }

  /* Stack dose session header */
  .cf-dose-session-header {
    flex-direction: column;
  }

  /* Leaderboard rows: tighter gap */
  .cf-leaderboard-row {
    gap: 0.4rem;
  }

  /* Quick actions: 2 columns forced */
  .cf-quick-actions {
    grid-template-columns: 1fr 1fr;
  }

  /* Subject tabs */
  .cf-subject-tab {
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
  }

  /* Plan table: allow horizontal scroll */
  .cf-plan-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ── Safe area insets (iPhone notch / home indicator) ── */
@supports (padding: env(safe-area-inset-bottom)) {
  .cf-sidebar {
    padding-bottom: env(safe-area-inset-bottom);
  }
  .cf-navbar {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }
  .cf-main-content {
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }
}

/* ── Landscape phone (short viewport, wide) ── */
@media (max-height: 500px) and (orientation: landscape) {
  :root {
    --cf-navbar-h: 52px;
  }
  .cf-sidebar-user {
    padding: 0.75rem 1rem 0.5rem;
  }
  .cf-sidebar-link {
    padding: 0.5rem 1rem;
    min-height: 40px;
  }
  .cf-dose-complete-banner {
    padding: 1.25rem 1.5rem;
  }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .cf-skeleton {
    animation: none;
    background: #e8e8e8;
  }
}

/* Dark mode support (intentionally minimal – tenant branding overrides) */
@media (prefers-color-scheme: dark) {
  /* Intentionally not implemented – tenant branding overrides */
}

/* Cards */
.cf-source-card {
  transition: all 0.2s ease;
  border-radius: 12px;
  cursor: pointer;
}

.cf-source-card:hover {
  background: var(--cf-accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.cf-source-card:active {
  transform: scale(0.98);
}
