/* ===== Design System Tokens ===== */
:root {
  /* Brand colors */
  --color-primary:        #3b82f6;
  --color-primary-dark:   #2563eb;
  --color-primary-darker: #1d4ed8;
  --color-primary-bg:     #eff6ff;
  --color-primary-light:  #dbeafe;

  /* Semantic colors */
  --color-success:        #10b981;
  --color-success-dark:   #16a34a;
  --color-success-bg:     #d1fae5;
  --color-success-light:  #f0fdf4;
  --color-error:          #dc2626;
  --color-error-dark:     #b91c1c;
  --color-error-bg:       #fee2e2;
  --color-error-light:    #fef2f2;
  --color-warning:        #f59e0b;
  --color-warning-dark:   #d97706;
  --color-warning-bg:     #fef3c7;
  --color-info:           #2563eb;

  /* Neutral palette */
  --color-dark:           #0f172a;
  --color-dark-2:         #1e293b;
  --color-dark-3:         #334155;
  --color-dark-4:         #475569;
  --color-muted:          #64748b;
  --color-muted-2:        #94a3b8;
  --color-border:         #e2e8f0;
  --color-border-light:   #f1f5f9;
  --color-bg:             #f8fafc;
  --color-bg-2:           #f5f5f5;
  --color-white:          #ffffff;

  /* Typography */
  --font-xs:   0.75rem;
  --font-sm:   0.82rem;
  --font-base: 1rem;
  --font-lg:   1.125rem;
  --font-xl:   1.25rem;

  /* Spacing */
  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;

  /* Border radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
  --radius-xl:  20px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:  0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg:  0 8px 24px rgba(0,0,0,0.12);

  /* Z-index layers */
  --z-sidebar:  100;
  --z-modal:    1000;
  --z-toast:    9999;

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
}

/* ===== Reset / Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--color-bg-2);
  color: #333;
  line-height: 1.5;
}

h1, h2, h3 {
  margin-top: 0;
}

a {
  color: #1a1a2e;
}

/* ===== Navbar ===== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #1a1a2e;
  color: #fff;
}

.navbar-title {
  font-weight: bold;
  font-size: 1.2rem;
}

.navbar-right {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.navbar-link {
  color: #fff;
  text-decoration: none;
}

.navbar-link:hover {
  text-decoration: underline;
}

.navbar button {
  background: transparent;
  color: #fff;
  border: 1px solid #fff;
  padding: 0.35rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.875rem;
}

.navbar button:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ===== Container ===== */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ===== Auth Container ===== */
.auth-container {
  max-width: 400px;
  margin: 4rem auto;
  padding: 2rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  text-align: center;
  color: #0f172a;
}

.auth-container h1 {
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  color: #0f172a;
}

.auth-container label {
  color: #334155;
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 1rem;
  text-align: left;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-weight: 600;
}

input,
textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

button[type="submit"],
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

button[type="submit"]:hover,
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

.btn-danger {
  background: var(--color-error);
  color: #fff;
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}

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

/* ===== Course Cards ===== */
#courses-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.course-card {
  background: #fff;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.3s ease;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  border-color: #3b82f6;
}

/* ===== Lessons List (student) ===== */
#lessons-panel ul {
  list-style: none;
  padding: 0;
}

#lessons-panel li {
  padding: 0.5rem 0;
  border-bottom: 1px solid #eee;
}

#lessons-panel a {
  text-decoration: none;
}

#lessons-panel a:hover {
  text-decoration: underline;
}

.lesson-completed-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: #d1fae5;
  color: #059669;
  font-size: 0.75rem;
  font-weight: 600;
  vertical-align: middle;
}

.back-to-top-btn {
  position: fixed;
  right: 28px;
  bottom: 28px;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.28);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s, background 0.2s ease;
  z-index: 400;
}

.back-to-top-btn.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top-btn:hover {
  background: rgba(29, 78, 216, 0.45);
}

body.dark-mode .back-to-top-btn {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .back-to-top-btn:hover {
  background: rgba(37, 99, 235, 0.4);
}

body.dark-mode .lesson-completed-badge {
  background: #052e1c;
  color: #86efac;
}

/* ===== Lesson Content ===== */
.lesson-content {
  background: #fff;
  padding: 2rem;
  border-radius: 8px;
  line-height: 1.7;
}

.lesson-content pre {
  background: #f8f8f8;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
}

.lesson-content code {
  background: #f8f8f8;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.lesson-content pre code {
  background: none;
  padding: 0;
}

.lesson-content img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1rem auto;
}

.lesson-content table,
.preview-panel table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.lesson-content th,
.preview-panel th {
  background: #f1f5f9;
  font-weight: 600;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border: 1px solid #e2e8f0;
}

.lesson-content td,
.preview-panel td {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e2e8f0;
}

.lesson-content tr:nth-child(even),
.preview-panel tr:nth-child(even) {
  background: #f8fafc;
}

.lesson-nav {
  display: flex;
  justify-content: space-between;
  margin-top: 2rem;
}

.lesson-nav button {
  padding: 0.5rem 1.25rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

.lesson-nav button:hover:not(:disabled) {
  background: #f0f0f0;
}

.lesson-nav button:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ===== Admin ===== */
.admin-course-group {
  margin-bottom: 2rem;
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.admin-course-group:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

.admin-course-group h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid #e2e8f0;
}

.admin-course-group ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.admin-lesson-item {
  display: flex;
  align-items: center;
  padding: 0.65rem 0;
  border-bottom: 1px solid #f1f5f9;
}

.admin-lesson-item:last-child {
  border-bottom: none;
}

.admin-lesson-item span {
  flex: 1;
  font-size: 0.95rem;
  text-align: left;
}

.admin-lesson-item .lesson-title-text {
  flex: 1;
  text-align: left;
}

.admin-lesson-item .drag-handle {
  flex: none;
}

.admin-lesson-item button {
  margin-left: 0.5rem;
  padding: 0.3rem 0.85rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  transition: all 0.15s;
}

.admin-lesson-item button:not(.btn-danger) {
  background: #f0f4ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
}

.admin-lesson-item button:not(.btn-danger):hover {
  background: #dbeafe;
}

.admin-lesson-item .btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.admin-lesson-item .btn-danger:hover {
  background: #fee2e2;
}

/* Mobile: the title + up to 5 action buttons (edit/view/lock/class-toggle/
   delete) never fit on one row, and previously just overflowed the card
   with no wrap -- the delete button in particular could end up entirely
   off-screen and unreachable. Wrap the title onto its own full-width line
   and let the buttons flow onto the next. The drag handle is hidden here
   because native HTML5 drag-and-drop (li.draggable=true) isn't supported
   by touch browsers anyway, so it's dead weight worth reclaiming the
   space from. */
@media (max-width: 768px) {
  .admin-lesson-item {
    flex-wrap: wrap;
    row-gap: 0.4rem;
  }

  .admin-lesson-item .drag-handle {
    display: none;
  }

  .admin-lesson-item .lesson-title-text {
    flex: 1 1 100%;
  }

  .admin-lesson-item button {
    margin-left: 0;
    margin-right: 0.4rem;
  }
}

/* Lesson drag-and-drop list */
.lesson-drag-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.admin-lesson-item.draggable-row {
  transition: background-color 0.15s ease;
  cursor: default;
}

.admin-lesson-item.draggable-row.dragging {
  opacity: 0.5;
  background: #f1f5f9;
}

.admin-lesson-item.lesson-locked .lesson-title-text {
  color: #94a3b8;
}

.admin-lesson-item.lesson-unlocked .lesson-title-text {
  color: #0f172a;
}

.admin-lesson-item.draggable-row.drag-over {
  border-top: 2px solid #2563eb;
  background: #eff6ff;
}

/* Lesson badge for quizzes/labs/homework */
.lesson-badge {
  display: inline-block;
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 12px;
  margin-left: 6px;
  vertical-align: middle;
}

.quiz-meta {
  color: #64748b;
  font-size: 0.82rem;
  margin-left: 8px;
}

/* ===== Editor ===== */
.editor-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 960px) {
  .editor-split {
    grid-template-columns: 1fr;
  }
}

.editor-pane textarea {
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  resize: vertical;
  flex: 1;
  padding: 1rem;
  border: none;
  border-radius: 0 0 12px 12px;
}

.editor-pane textarea:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.preview-panel {
  background: #fff;
  padding: 1rem;
  border: none;
  border-radius: 0 0 12px 12px;
  min-height: 400px;
  overflow-y: auto;
  line-height: 1.7;
  flex: 1;
}

.preview-panel pre {
  background: #f8f8f8;
  padding: 1rem;
  border-radius: 4px;
  overflow-x: auto;
}

.preview-panel code {
  background: #f8f8f8;
  padding: 0.15rem 0.35rem;
  border-radius: 3px;
  font-size: 0.9em;
}

.preview-panel pre code {
  background: none;
  padding: 0;
}

.editor-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

/* ===== Messages ===== */
.error-message {
  color: var(--color-error);
  margin-top: 0.5rem;
}

.success-message {
  color: var(--color-success-dark);
  margin-top: 0.5rem;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .editor-split {
    grid-template-columns: 1fr;
  }

  .navbar {
    flex-direction: column;
    text-align: center;
  }

  .navbar-right {
    margin-top: 0.5rem;
  }
}

/* ── Admin Sidebar Layout ──────────────────────────────────── */

body.admin-layout {
  margin: 0;
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 250px;
  min-width: 250px;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: width 0.25s ease, min-width 0.25s ease;
}

/* Collapsed sidebar */
.sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}

.sidebar.collapsed .sidebar-header-text,
.sidebar.collapsed .nav-section-title {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 16px 8px;
}

.sidebar.collapsed .sidebar-nav-item {
  padding: 12px 0;
  justify-content: center;
  margin: 0;
  width: 100%;
  border-radius: 0;
}

.sidebar.collapsed .nav-label {
  display: none;
}

.sidebar.collapsed .nav-icon {
  font-size: 1.2rem;
}

.sidebar.collapsed .sidebar-footer {
  padding: 8px;
}

.sidebar.collapsed .sidebar-logout {
  padding: 10px 0;
  display: flex;
  justify-content: center;
}

.sidebar.collapsed .sidebar-logout .nav-label {
  display: none;
}

.sidebar-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-header-text {
  overflow: hidden;
}

.sidebar-logo {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 6px;
}

.sidebar-user {
  font-size: 0.75rem;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.45;
  padding: 10px 20px 4px;
  font-weight: 600;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  margin: 0 8px;
  width: calc(100% - 16px);
  border: none;
  background: none;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s ease;
  border-radius: 8px;
}

.nav-icon {
  flex-shrink: 0;
  font-size: 1rem;
  line-height: 1;
}

.nav-label {
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.sidebar-nav-item.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logout {
  width: 100%;
  padding: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.sidebar-logout:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.admin-content {
  flex: 1;
  padding: 40px;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 100vh;
  overflow-y: auto;
  background: #f8fafc;
}

/* Tab header — title + create button on same line with spacing */
.tab-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.tab-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

/* Grading iframe */
.grading-iframe {
  width: 100%;
  height: calc(100vh - 120px);
  border: none;
  border-radius: 12px;
}

/* Hide old top-bar elements when sidebar is present */
body.admin-layout .navbar,
body.admin-layout .admin-tabs {
  display: none;
}

/* Sidebar responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 200px;
    min-width: 200px;
  }

  .sidebar.collapsed {
    width: 56px;
    min-width: 56px;
  }

  .admin-content {
    padding: 25px;
  }
}

@media (max-width: 480px) {
  .sidebar {
    width: 56px;
    min-width: 56px;
  }

  .sidebar-header-text,
  .nav-section-title,
  .sidebar-footer {
    display: none;
  }

  .sidebar-nav-item {
    padding: 12px 0;
    justify-content: center;
    font-size: 1.1rem;
  }

  .admin-content {
    padding: 15px;
  }
}

/* ── Active Class Banner — persistent, always visible above every tab ── */
.active-class-banner {
  display: flex;
  align-items: center;
  margin: 0 0 24px 0;
  padding: 14px 20px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: filter 0.15s ease;
}

.active-class-banner:hover {
  filter: brightness(0.98);
}

.active-class-banner-content {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 0.9rem;
}

.active-class-banner-label {
  color: #64748b;
  font-weight: 500;
}

.active-class-banner-caret {
  margin-left: 4px;
  opacity: 0.6;
}

/* "All Classes" state — neutral/gray, deliberate overview mode */
.active-class-banner--all {
  background: #f8fafc;
  border-left: 4px solid #94a3b8;
}
.active-class-banner--all .active-class-banner-name {
  color: #475569;
}

/* Active-class state — branded/colored, visually distinct at a glance */
.active-class-banner--active {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
}
.active-class-banner--active .active-class-banner-name {
  color: #1d4ed8;
}

/* Class switcher modal list */
.class-switcher-list {
  max-height: 60vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.class-switcher-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease;
}

.class-switcher-item:hover {
  background: #f1f5f9;
}

.class-switcher-item.current {
  background: #eff6ff;
  border-color: #bfdbfe;
  font-weight: 600;
}

.class-switcher-item-name {
  font-size: 0.9rem;
  color: #1a1a2e;
}

.class-switcher-item-status {
  font-size: 0.75rem;
  color: #64748b;
}

@media (max-width: 480px) {
  .active-class-banner-label {
    display: none;
  }
}

/* ── Admin Tabs ────────────────────────────────────────────── */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 2rem;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0;
}

.tab-btn {
  padding: 10px 24px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #64748b;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}

.tab-btn:hover { color: #334155; }

.tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

/* ── Admin Table ───────────────────────────────────────────── */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 16px 30px;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  color: #334155;
}

.admin-table th {
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  background: #f8fafc;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0;
}

.admin-table tr:hover { background: #f8fafc; }

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-active { background: #dcfce7; color: #166534; }
.status-pending { background: #fef3c7; color: #92400e; }

.btn-small {
  padding: 4px 12px;
  font-size: 0.82rem;
  border: 1px solid #cbd5e1;
  background: white;
  border-radius: 6px;
  cursor: pointer;
}

.btn-small:hover { background: #f1f5f9; }

.btn-small.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.btn-small.btn-primary:hover {
  background: #1d4ed8;
}

.btn-small.btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-small.btn-danger:hover {
  background: #fee2e2;
}

.btn-reset-quiz {
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
  white-space: nowrap;
}

.btn-reset-quiz:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

/* ── User Actions ──────────────────────────────────────────── */
.user-actions {
  display: flex;
  gap: 4px;
  flex-wrap: nowrap;
}

.user-actions .btn-small {
  white-space: nowrap;
  font-size: 0.78rem;
  padding: 3px 8px;
}

.user-actions .btn-danger {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.user-actions .btn-danger:hover {
  background: #fee2e2;
}

.class-assign-select {
  padding: 3px 6px;
  font-size: 0.78rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #f0f4ff;
  color: #2563eb;
  cursor: pointer;
  font-weight: 500;
}

.class-assign-select:focus {
  outline: none;
  border-color: #2563eb;
}

.user-disabled td {
  opacity: 0.5;
}

.status-disabled {
  background: #fee2e2;
  color: #991b1b;
}

/* ── Course Actions ────────────────────────────────────────── */
.course-actions {
  display: flex;
  gap: 4px;
}

/* ── Course Order (Drag & Drop) ────────────────────────────── */
.course-order-cell {
  white-space: nowrap;
}

.course-order-num {
  display: inline-block;
  width: 20px;
  text-align: center;
  font-weight: 600;
  font-size: 0.85rem;
  color: #475569;
  vertical-align: middle;
}

.drag-handle {
  cursor: grab;
  font-size: 1rem;
  color: #94a3b8;
  vertical-align: middle;
  user-select: none;
  padding-right: 4px;
}

.drag-handle:hover {
  color: #475569;
}

.draggable-row {
  transition: background-color 0.15s ease;
}

.draggable-row.dragging {
  opacity: 0.5;
  background: #f1f5f9;
}

.draggable-row.drag-over {
  border-top: 2px solid #2563eb;
  background: #eff6ff;
}

/* ── Training Matrix (new design) ──────────────────────────── */
.matrix-container {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

.matrix-header {
  background: #f8fafc;
  padding: 16px 24px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.matrix-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.matrix-title {
  font-size: 18px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}

.matrix-class-badge {
  font-size: 12px;
  padding: 4px 10px;
  background: #eff6ff;
  color: #2563eb;
  border-radius: 4px;
  font-weight: 500;
}

.matrix-header-actions {
  display: flex;
  gap: 8px;
}

.matrix-action-btn {
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid #e2e8f0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: #64748b;
  transition: all 0.15s;
}

.matrix-action-btn:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.matrix-search-box {
  padding: 12px 24px;
  border-bottom: 1px solid #e2e8f0;
  background: #fff;
}

.matrix-search-input {
  width: 100%;
  max-width: 320px;
  padding: 8px 12px 8px 36px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  background: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%23888' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='4'/%3E%3Cpath d='M11 11l3 3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px center;
  color: #0f172a;
}

.matrix-search-input::placeholder {
  color: #94a3b8;
}

.matrix-table-wrapper {
  overflow-x: auto;
}

.matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.matrix-table thead {
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 10;
}

.matrix-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  font-size: 13px;
  color: #64748b;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.matrix-th-student {
  min-width: 260px;
}

.matrix-th-course {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: center;
  padding: 12px 8px;
  min-width: 48px;
}

.matrix-th-course-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.matrix-th-progress {
  min-width: 120px;
  text-align: center;
}

.matrix-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}

.matrix-table tbody tr:hover {
  background: rgba(0, 0, 0, 0.02);
}

/* Student row */
.matrix-student-row {
  background: #fff;
  cursor: pointer;
}

.matrix-student-row.matrix-row-expanded {
  background: #f8fafc;
}

.matrix-student-cell {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.matrix-expand-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  transition: transform 0.2s;
  flex-shrink: 0;
  font-size: 14px;
}

.matrix-row-expanded > .matrix-student-cell > .matrix-expand-icon,
.matrix-module-expanded > .matrix-module-cell > .matrix-expand-icon {
  transform: rotate(90deg);
}

.matrix-student-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.matrix-student-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.matrix-student-name {
  font-weight: 500;
  color: #0f172a;
}

/* Module row */
.matrix-module-row {
  background: #fff;
}

.matrix-module-row.matrix-module-expanded {
  background: rgba(0, 0, 0, 0.02);
}

.matrix-module-cell {
  padding: 10px 16px 10px 60px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.matrix-module-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.matrix-module-name {
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

/* Item row */
.matrix-item-row {
  background: #fff;
}

.matrix-item-cell {
  padding: 8px 16px 8px 84px;
  font-size: 13px;
  color: #94a3b8;
}

/* Grade cell */
.matrix-grade-cell {
  padding: 12px 16px;
  text-align: center;
}

/* Status circles */
.matrix-status-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  transition: transform 0.1s;
}

.matrix-status-circle:hover {
  transform: scale(1.1);
}

.matrix-status-complete {
  background: #d1fae5;
  color: #059669;
}

.matrix-status-partial {
  background: #fef3c7;
  color: #d97706;
}

.matrix-status-pending {
  background: #f1f5f9;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
}

/* Item indicators */
.matrix-item-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 500;
}

.matrix-item-quiz {
  background: rgba(147, 51, 234, 0.15);
  color: rgb(147, 51, 234);
}

.matrix-item-lab {
  background: rgba(59, 130, 246, 0.15);
  color: rgb(59, 130, 246);
}

.matrix-item-homework {
  background: rgba(16, 185, 129, 0.15);
  color: rgb(16, 185, 129);
}

.matrix-item-complete {
  background: #d1fae5;
  color: #059669;
}

.matrix-item-pending {
  background: #f1f5f9;
  color: #94a3b8;
  border: 1px solid #e2e8f0;
}

.matrix-item-failed {
  background: #fee2e2;
  color: #dc2626;
}

/* Stats / Progress */
.matrix-stats-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.matrix-stat-value {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
}

.matrix-progress-bar {
  width: 80px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.matrix-progress-fill {
  height: 100%;
  background: #10b981;
  border-radius: 3px;
  transition: width 0.3s;
}

/* Course column progress bars */
.matrix-course-progress {
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-course-bar {
  width: 60px;
  height: 5px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.matrix-course-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.matrix-course-pct {
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
  min-width: 32px;
}

/* Summary row */
.matrix-summary-row {
  background: #f8fafc;
  font-weight: 500;
}

.matrix-summary-row td {
  padding: 14px 16px;
  font-size: 13px;
  color: #475569;
}

.matrix-summary-label {
  padding-left: 16px !important;
  font-weight: 600;
  color: #0f172a;
}

@media (max-width: 768px) {
  .matrix-header { flex-direction: column; gap: 12px; align-items: flex-start; }
  .matrix-th-course { min-width: 40px; }
  .matrix-student-cell { padding: 10px 12px; }
  .matrix-module-cell { padding-left: 40px; }
  .matrix-item-cell { padding-left: 60px; }
}

/* ── Modal ─────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  position: relative;
  animation: modalSlideIn 0.2s ease-out;
}

.modal-sm {
  max-width: 360px;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 16px;
  font-weight: 500;
  color: #0f172a;
}

.btn-close {
  width: 30px;
  height: 30px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 18px;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.form-field {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #64748b;
  margin-bottom: 6px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row .form-field {
  margin-bottom: 16px;
}

.modal .form-input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  transition: border-color 0.15s;
}

.modal .form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal .form-input:disabled {
  background: #f8fafc;
  color: #94a3b8;
  cursor: not-allowed;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
}

.btn-cancel {
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  color: #0f172a;
}

.btn-cancel:hover {
  background: #f8fafc;
}

.btn-save {
  padding: 8px 16px;
  background: #1a6ef5;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-save:hover {
  background: #155dd4;
}

.btn-reset-pw {
  padding: 8px 16px;
  background: #f59e0b;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  margin-right: auto;
}

.btn-reset-pw:hover {
  background: #d97706;
}

.btn-delete {
  padding: 8px 16px;
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.btn-delete:hover {
  background: #fee2e2;
}

/* Delete confirm modal */
.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fef2f2;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin: 0 auto 16px;
}

.confirm-title {
  font-size: 16px;
  font-weight: 500;
  color: #0f172a;
  margin-bottom: 6px;
}

.confirm-desc {
  font-size: 14px;
  color: #64748b;
  margin-bottom: 0;
}

/* ── Students Table Design ─────────────────────────────────── */
.page-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 22px;
  font-weight: 500;
  color: #0f172a;
  margin: 0 0 4px;
}

.page-subtitle {
  font-size: 14px;
  color: #64748b;
  margin: 0;
}

.students-table-wrap {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

.students-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.students-table thead {
  background: #f8fafc;
}

.students-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: #64748b;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid #e2e8f0;
}

.students-table td {
  padding: 14px 16px;
  color: #0f172a;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.students-table tbody tr:last-child td {
  border-bottom: none;
}

.students-table tbody tr:hover {
  background: #f8fafc;
}

.student-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.student-cell .avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.student-cell .student-name {
  font-weight: 500;
  font-size: 14px;
  color: #0f172a;
}

.student-cell .student-email {
  font-size: 12px;
  color: #64748b;
  margin-top: 1px;
}

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-status.active {
  background: #d1fae5;
  color: #059669;
}

.badge-status.disabled {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.badge-status .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-status.active .status-dot {
  background: #059669;
}

.badge-status.disabled .status-dot {
  background: #94a3b8;
}

.badge-status.new {
  background: #eff6ff;
  color: #2563eb;
}

.badge-status.new .status-dot {
  background: #2563eb;
}

.badge-status.contacted {
  background: #fef3c7;
  color: #d97706;
}

.badge-status.contacted .status-dot {
  background: #d97706;
}

.badge-status.enrolled {
  background: #d1fae5;
  color: #059669;
}

.badge-status.enrolled .status-dot {
  background: #059669;
}

.badge-status.dismissed {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.badge-status.dismissed .status-dot {
  background: #94a3b8;
}

.badge-status.pending {
  background: #eff6ff;
  color: #2563eb;
}

.badge-status.pending .status-dot {
  background: #2563eb;
}

.badge-status.past_due {
  background: #fef3c7;
  color: #d97706;
}

.badge-status.past_due .status-dot {
  background: #d97706;
}

.badge-status.canceled {
  background: #fee2e2;
  color: #dc2626;
}

.badge-status.canceled .status-dot {
  background: #dc2626;
}

/* Enrollment Inquiries' status pill wraps a real <select> so it stays a
   native, accessible control -- styled to disappear into the colored
   badge around it instead of showing as a plain white dropdown box. */
.badge-status:has(.enrollment-status-select) {
  padding: 4px 8px 4px 10px;
  cursor: pointer;
  transition: filter 0.12s ease;
}

.badge-status:has(.enrollment-status-select):hover {
  filter: brightness(0.96);
}

.enrollment-status-select {
  appearance: none;
  -webkit-appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  padding: 0 16px 0 0;
  margin: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10' fill='none'%3E%3Cpath d='M2.5 4L5 6.5L7.5 4' stroke='%2364748b' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right center;
}

.enrollment-status-select:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 4px;
}

.student-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Students skeleton loader ─────────────────────────────────────────────── */

@keyframes students-shimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}

.skel {
  background: linear-gradient(90deg, #f1f5f9 25%, #e8edf4 50%, #f1f5f9 75%);
  background-size: 600px 100%;
  animation: students-shimmer 1.4s ease-in-out infinite;
  border-radius: 5px;
  display: block;
}

.skel-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
}

.skel-name {
  height: 13px;
  margin-bottom: 5px;
}

.skel-email {
  height: 11px;
}

.skel-line {
  height: 13px;
}

.skel-badge {
  height: 22px;
  border-radius: 20px;
}

.skel-icon {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-block;
}

.skeleton-row td {
  padding: 12px 14px;
}

.skeleton-row .student-cell {
  gap: 10px;
}

.skeleton-row .skel-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  font-size: 14px;
  transition: all 0.12s;
}

.btn-icon:hover {
  background: #f8fafc;
  color: #0f172a;
}

.btn-icon.danger:hover {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.btn-icon.remove {
  color: #dc2626;
  border-color: #fecaca;
  font-size: 16px;
  font-weight: 700;
}

.btn-icon.remove:hover {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #dc2626;
}

.btn-secondary {
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  background: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

/* ── Toast Notifications ───────────────────────────────────── */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 300px;
  max-width: 420px;
  pointer-events: auto;
  animation: toastSlideIn 0.3s ease-out;
  transition: opacity 0.3s, transform 0.3s;
}

.toast.toast-hiding {
  opacity: 0;
  transform: translateX(20px);
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

.toast-icon {
  font-size: 18px;
  flex-shrink: 0;
  margin-top: 1px;
}

.toast-content {
  flex: 1;
}

.toast-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 2px;
}

.toast-message {
  font-size: 13px;
  color: #64748b;
  line-height: 1.4;
}

.toast-close {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 16px;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  flex-shrink: 0;
}

.toast-close:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.toast.toast-error {
  border-left: 4px solid #dc2626;
}

.toast.toast-success {
  border-left: 4px solid #10b981;
}

.toast.toast-info {
  border-left: 4px solid #2563eb;
}

.toast.toast-warning {
  border-left: 4px solid #f59e0b;
}

/* ── Reports Page ──────────────────────────────────────────── */
.reports-filters {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.reports-search-wrap {
  flex: 1;
  min-width: 200px;
}

.reports-filters .form-input {
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}

.reports-filters select.form-input {
  min-width: 140px;
}

/* Report submission table */
.reports-table {
  border-collapse: separate;
  border-spacing: 0;
}

.reports-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
}

.reports-table tbody tr:hover {
  background: #f8fafc;
}

.report-student-cell {
  padding: 16px 30px !important;
}

.report-student-name {
  font-weight: 700;
  font-size: 14px;
  color: #0f172a;
  margin-bottom: 2px;
}

.report-student-email {
  font-size: 12px;
  color: #94a3b8;
}

.report-attempts {
  font-weight: 400;
  font-size: 12px;
  color: #64748b;
}

.report-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: 'Courier New', monospace;
}

.report-pass {
  background: #d1fae5;
  color: #065f46;
}

.report-review {
  background: #fef3c7;
  color: #92400e;
}

.report-fail {
  background: #fee2e2;
  color: #991b1b;
}

.report-points {
  font-weight: 600;
  font-size: 15px;
  color: #0f172a;
}

.report-date {
  color: #64748b;
  font-size: 13px;
}

/* Expandable rows */
.report-expandable {
  cursor: pointer;
}

.report-expandable:hover {
  background: #f1f5f9;
}

.report-toggle {
  display: inline-block;
  width: 16px;
  font-size: 11px;
  color: #64748b;
  transition: transform 0.2s;
}

.report-expanded .report-toggle {
  color: #2563eb;
}

.report-detail-row {
  background: #f8fafc;
}

.report-detail-row td {
  padding-top: 8px !important;
  padding-bottom: 8px !important;
  font-size: 12px;
  color: #64748b;
  border-bottom: 1px solid #f1f5f9;
}

.report-detail-label {
  font-weight: 500;
  color: #475569 !important;
}

@media (max-width: 768px) {
  .reports-filters {
    flex-direction: column;
  }
  .reports-search-wrap {
    width: 100%;
  }
}

/* ── Settings Page ─────────────────────────────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.settings-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.settings-card h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 2px solid #e2e8f0;
}

.settings-item {
  margin-bottom: 16px;
}

.settings-item:last-of-type {
  margin-bottom: 0;
}

.settings-item > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.settings-value {
  font-size: 14px;
  color: #0f172a;
  font-weight: 500;
  padding: 8px 0;
}

.settings-value a {
  color: #2563eb;
  text-decoration: none;
}

.settings-value a:hover {
  text-decoration: underline;
}

.settings-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-btn:hover {
  background: #1e40af;
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(37, 99, 235, 0.25);
}

.settings-current-admin {
  display: flex;
  align-items: center;
  gap: 16px;
}

.settings-admin-avatar {
  width: 48px;
  height: 48px;
  background: #ede9fe;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.settings-editable {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.settings-editable .form-input {
  flex: 1;
  min-width: 150px;
}

@media (max-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Mermaid Diagrams ──────────────────────────────────────── */
.mermaid-diagram {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0;
  text-align: center;
  overflow-x: auto;
}

.mermaid-diagram svg {
  max-width: 100%;
  height: auto;
}

/* ── Editor Page (Wider layout for split-pane editing) ────────── */
.editor-page {
  max-width: 1400px;
}

.lesson-meta-bar {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
}

.editor-notification {
  display: none;
  position: fixed;
  top: 80px;
  right: 20px;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  animation: slideInRight 0.3s ease-out, slideOutRight 0.3s ease-out 4.7s forwards;
  max-width: 400px;
}

.editor-notification.success {
  display: block;
  background: #d1fae5;
  color: #065f46;
  border: 1px solid #6ee7b7;
}

.editor-notification.error {
  display: block;
  background: #fee2e2;
  color: #7f1d1d;
  border: 1px solid #fca5a5;
}

@keyframes slideInRight {
  from {
    transform: translateX(450px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(450px);
    opacity: 0;
  }
}

.lesson-meta-section {
  display: flex;
  flex-direction: column;
  min-width: 180px;
}

.lesson-meta-section label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: #475569;
}

.lesson-meta-section select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.95rem;
}

.lesson-title-section {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.lesson-title-input {
  border: none !important;
  font-size: 1.6rem !important;
  font-weight: 600;
  color: #0f172a;
  padding: 0.35rem 0 !important;
  margin: 0 !important;
}

.lesson-title-input:focus {
  outline: none;
  border-bottom: 2px solid #3b82f6 !important;
  box-shadow: none !important;
}

.lesson-actions {
  display: flex;
  gap: 0.5rem;
}

/* ── Editor Pane Cards ──────────────────────────────────────── */
.pane-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.pane-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  font-weight: 600;
  font-size: 0.9rem;
  color: #334155;
}

.editor-pane {
  display: flex;
  flex-direction: column;
}

.preview-pane .pane-header {
  background: #f0f9ff;
  color: #075985;
}

/* ── Editor Toolbar & Image Upload ─────────────────────────── */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.upload-status {
  font-size: 0.82rem;
}

.insert-dropdown {
  position: relative;
  display: inline-block;
}

.insert-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 20;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  min-width: 180px;
  padding: 4px;
  display: flex;
  flex-direction: column;
}

.insert-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: 6px;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
  color: #0f172a;
}

.insert-menu-item:hover {
  background: #f1f5f9;
}

/* Video / YouTube / HTML embed content blocks (lesson viewer + editor preview) */
.lesson-content video {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  margin: 1rem auto;
}

.video-embed {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16 / 9;
  margin: 1rem auto;
  border-radius: 8px;
  overflow: hidden;
  background: #000;
}

.video-embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.html-embed-frame {
  display: block;
  width: 100%;
  max-width: 720px;
  min-height: 400px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  margin: 1rem auto;
  background: #fff;
}

/* Preview Modal (Student View) */
.preview-modal-content {
  background: #fff;
  width: 90%;
  max-width: 900px;
  height: 85vh;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.preview-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.preview-modal-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #0f172a;
}

.preview-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 2rem 3rem;
}

textarea.drag-over {
  border-color: #2563eb;
  background: #f0f4ff;
}

.lesson-content img,
.preview-panel img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  margin: 0.5rem auto;
  border: 1px solid #e2e8f0;
}

/* ── Course Select ─────────────────────────────────────────── */
.course-select-wrap {
  display: flex;
  gap: 0.5rem;
}

.course-select-wrap select {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  background: #fff;
}

.course-select-wrap input {
  flex: 1;
}

/* ── Lesson Gating ─────────────────────────────────────────── */
.gating-message {
  background: #fef3c7;
  border: 1px solid #f59e0b;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  color: #92400e;
  line-height: 1.6;
}

.gating-message p {
  margin: 0 0 0.75rem;
}

.gating-message p:last-child {
  margin-bottom: 0;
}

/* ── Quiz Editor ───────────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 1rem;
}

.form-half {
  flex: 1;
}

.questions-section {
  margin-top: 2rem;
}

.questions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.questions-header h3 {
  margin: 0;
}

.question-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.question-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.question-number {
  font-weight: 600;
  color: #1a1a2e;
}

.question-card-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.question-type-select {
  padding: 0.3rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.875rem;
  background: #fff;
}

.question-body {
  margin-top: 0.75rem;
}

/* MC options */
.mc-option-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.mc-option-row input[type="radio"] {
  width: auto;
  flex-shrink: 0;
}

.mc-option-input {
  flex: 1;
}

.mc-options-list {
  margin-bottom: 0.5rem;
}

/* TF options */
.tf-options {
  display: flex;
  gap: 1.5rem;
}

.tf-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-weight: normal;
  cursor: pointer;
}

.tf-label input[type="radio"] {
  width: auto;
}

/* FITB answers */
.fitb-answer-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.fitb-answer-input {
  flex: 1;
}

.fitb-answers-list {
  margin-bottom: 0.5rem;
}

.add-option-btn,
.add-answer-btn {
  margin-top: 0.25rem;
}

@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
    gap: 0;
  }

  .question-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
}


/* ── Quiz Taking ───────────────────────────────────────────── */
.quiz-meta {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.quiz-question-area {
  min-height: 200px;
}

.quiz-question-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.quiz-question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #f1f5f9;
}

.quiz-question-type {
  font-size: 0.82rem;
  color: #64748b;
  background: #f1f5f9;
  padding: 2px 10px;
  border-radius: 12px;
}

.quiz-question-text {
  font-size: 1.05rem;
  margin-bottom: 1.25rem;
  line-height: 1.6;
}

.quiz-answer-area {
  padding-left: 0.25rem;
}

/* MC options (quiz taking) */
.quiz-mc-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.4rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: normal;
  transition: background 0.15s;
}

.quiz-mc-option:hover {
  background: #f8fafc;
}

.quiz-mc-option input[type="radio"] {
  width: auto;
  flex-shrink: 0;
}

/* TF options (quiz taking) */
.quiz-tf-options {
  display: flex;
  gap: 1.5rem;
}

.quiz-tf-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.25rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: normal;
  transition: background 0.15s;
}

.quiz-tf-option:hover {
  background: #f8fafc;
}

.quiz-tf-option input[type="radio"] {
  width: auto;
}

/* FITB input (quiz taking) */
.fitb-quiz-input {
  max-width: 400px;
}

/* Navigation */
.quiz-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 1.5rem;
}

.quiz-nav button {
  padding: 0.5rem 1.25rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 0.95rem;
}

.quiz-nav button:hover:not(:disabled) {
  background: #f0f0f0;
}

.quiz-nav button:disabled {
  opacity: 0.5;
  cursor: default;
}

.question-indicator {
  font-size: 0.9rem;
  color: #64748b;
  font-weight: 600;
}

/* Question dots */
.quiz-question-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.quiz-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid #cbd5e1;
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  padding: 0;
}

.quiz-dot:hover {
  border-color: #1a1a2e;
  color: #1a1a2e;
}

.quiz-dot.active {
  background: #1a1a2e;
  border-color: #1a1a2e;
  color: #fff;
}

.quiz-dot.answered:not(.active) {
  background: #dbeafe;
  border-color: #2563eb;
  color: #2563eb;
}

/* Submit area */
.quiz-submit-area {
  margin-top: 1.5rem;
  text-align: center;
}

/* Previous result display */
.quiz-previous-result {
  text-align: center;
  padding: 2rem;
}

.quiz-prev-badge {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 2.5rem;
  border-radius: 12px;
  margin-bottom: 1rem;
}

.quiz-prev-badge.passed {
  background: #f0fdf4;
  border: 2px solid #86efac;
}

.quiz-prev-badge.failed {
  background: #fef2f2;
  border: 2px solid #fca5a5;
}

.quiz-prev-score {
  font-size: 2rem;
  font-weight: 700;
}

.quiz-prev-badge.passed .quiz-prev-score { color: #166534; }
.quiz-prev-badge.failed .quiz-prev-score { color: #dc2626; }

.quiz-prev-label {
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 4px;
}

.quiz-prev-badge.passed .quiz-prev-label { color: #166534; }
.quiz-prev-badge.failed .quiz-prev-label { color: #dc2626; }

.quiz-previous-result p {
  color: #64748b;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ── Quiz Results ──────────────────────────────────────────── */
.results-summary {
  text-align: center;
  margin-bottom: 2rem;
}

/* Gauge container */
.results-gauge-container {
  text-align: center;
  padding: 2rem 1rem;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

/* Circular ring */
.results-ring-wrapper {
  position: relative;
  display: inline-block;
  width: 160px;
  height: 160px;
  margin-bottom: 1rem;
}

.results-ring {
  display: block;
}

.results-ring-progress {
  transition: stroke-dashoffset 0.8s ease;
  animation: ring-fill 1s ease-out forwards;
}

@keyframes ring-fill {
  from { stroke-dashoffset: 339.292; }
}

.results-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.results-ring-score {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.1;
}

.results-ring-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 2px;
}

.results-ring-label.passed { color: #16a34a; }
.results-ring-label.failed { color: #dc2626; }

.results-ring-sublabel {
  display: block;
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 2px;
}

/* Pass/fail badge below ring */
.results-pass-badge {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 16px;
  border-radius: 20px;
  margin-top: 0.75rem;
  margin-bottom: 0.5rem;
}

.results-pass-badge.passed {
  color: #166534;
  border: 1.5px solid #86efac;
  background: #f0fdf4;
}

.results-pass-badge.failed {
  color: #991b1b;
  border: 1.5px solid #fca5a5;
  background: #fef2f2;
}

body.dark-mode .results-pass-badge.passed {
  color: #4ade80;
  border-color: #166534;
  background: #052e16;
}

body.dark-mode .results-pass-badge.failed {
  color: #fca5a5;
  border-color: #991b1b;
  background: #450a0a;
}

/* Motivational message */
.results-message {
  font-size: 0.95rem;
  margin: 0.5rem 0 1.5rem;
  color: #64748b;
}

.results-message-pass { color: #16a34a; }
.results-message-fail { color: #64748b; }

/* Linear progress bar */
.results-progress-bar-container {
  max-width: 500px;
  margin: 0 auto 1.5rem;
}

.results-progress-bar {
  position: relative;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: visible;
}

.results-progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
  animation: bar-fill 0.8s ease-out forwards;
}

@keyframes bar-fill {
  from { width: 0; }
}

.results-progress-fill.passed { background: #16a34a; }
.results-progress-fill.failed { background: #dc2626; }

.results-progress-pass-mark {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  background: #64748b;
  border-radius: 1px;
  transform: translateX(-50%);
}

.results-progress-score-label {
  position: absolute;
  top: -22px;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: #334155;
  white-space: nowrap;
}

.results-progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  color: #64748b;
}

.results-pass-mark-label {
  color: #16a34a;
  font-weight: 500;
}

/* Stats row */
.results-stats-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.results-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem 2rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  min-width: 120px;
}

.results-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.results-stat-correct { color: #16a34a; }
.results-stat-wrong { color: #dc2626; }

.results-stat-label {
  font-size: 0.8rem;
  color: #64748b;
  margin-top: 4px;
  text-transform: capitalize;
}

/* Results details / question review */
.results-details {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border: 1px solid #e2e8f0;
}

.results-details h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  color: #0f172a;
}

.result-review-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 0.75rem;
}

.result-review-card.result-correct {
  border-left: 3px solid #16a34a;
}

.result-review-card.result-incorrect {
  border-left: 3px solid #dc2626;
}

.result-review-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.result-icon {
  font-size: 1.1rem;
  font-weight: 700;
  width: 24px;
  text-align: center;
  flex-shrink: 0;
}

.result-question-text {
  font-size: 0.9rem;
  color: #334155;
}

.result-review-answers {
  margin-top: 8px;
  padding-left: 32px;
  font-size: 0.85rem;
}

.result-your-answer {
  color: #dc2626;
}

.results-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* ── Attempt History (Redesigned) ─────────────────────────── */
.quiz-attempt-history {
  text-align: left;
  margin: 1.5rem auto;
  max-width: 600px;
}

.attempt-history-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 0.75rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.attempt-history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.attempt-details-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.attempt-details-item:hover {
  border-color: #cbd5e1;
}

.attempt-details-item.best-attempt {
  background: #f0fdf4;
  border-color: #86efac;
}

.attempt-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  font-size: 0.9rem;
  color: #334155;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.attempt-summary::-webkit-details-marker {
  display: none;
}

.attempt-summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attempt-summary-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.attempt-icon {
  font-size: 1rem;
}

.attempt-number {
  font-weight: 600;
  color: #0f172a;
}

.attempt-status-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: capitalize;
}

.attempt-passed {
  color: #166534;
  background: #dcfce7;
}

.attempt-failed {
  color: #991b1b;
  background: #fee2e2;
}

.attempt-best-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: #16a34a;
}

.attempt-mini-bar {
  display: inline-block;
  width: 80px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.attempt-mini-bar-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  animation: bar-fill 0.6s ease-out forwards;
}

.attempt-score-pct {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  min-width: 36px;
  text-align: right;
}

.attempt-chevron {
  font-size: 0.7rem;
  color: #94a3b8;
  transition: transform 0.2s;
}

.attempt-details-item[open] .attempt-chevron {
  transform: rotate(180deg);
}

/* Expanded details */
.attempt-details-content {
  padding: 12px 16px 16px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}

.attempt-detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
}

.attempt-detail-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #334155;
}

.attempt-detail-icon {
  font-size: 0.85rem;
}

.attempt-detail-icon.correct { color: #16a34a; }
.attempt-detail-icon.wrong { color: #dc2626; }

.attempt-detail-val {
  margin-left: auto;
  font-weight: 600;
}

.attempt-detail-val.correct { color: #16a34a; }
.attempt-detail-val.wrong { color: #dc2626; }

.attempt-detail-date {
  margin-top: 10px;
  font-size: 0.8rem;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.results-attempt-history {
  margin: 1.5rem 0;
}

/* Results best score */
.results-best-score {
  margin-top: 1rem;
  font-size: 0.95rem;
  color: #334155;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.results-best-score.new-best {
  color: #166534;
  font-weight: 600;
}

.best-score-icon {
  font-size: 1.1rem;
}

.new-best-badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #16a34a;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 4px;
}

/* ── Quiz Results — Responsive ────────────────────────────── */
@media (max-width: 768px) {
  .quiz-tf-options {
    flex-direction: column;
    gap: 0.5rem;
  }

  .results-stats-row {
    gap: 0.5rem;
  }

  .results-stat-card {
    padding: 0.75rem 1rem;
    min-width: 90px;
  }

  .results-stat-value {
    font-size: 1.4rem;
  }

  .results-ring-wrapper {
    width: 130px;
    height: 130px;
  }

  .results-ring {
    width: 130px;
    height: 130px;
  }

  .results-ring-score {
    font-size: 1.6rem;
  }

  .attempt-mini-bar {
    width: 50px;
  }

  .attempt-detail-grid {
    grid-template-columns: 1fr;
  }

  .results-actions {
    flex-direction: column;
    align-items: center;
  }
}

/* ── Quiz Grading Policy — Due Date, Attempts ─────────────── */

.quiz-due-date {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin: 0.75rem 0;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.quiz-due-date-label {
  font-weight: 600;
  color: #1e40af;
}

.quiz-due-date-value {
  color: #1e40af;
}

.quiz-due-date-value.past-due {
  color: #dc2626;
  font-weight: 600;
}

.quiz-attempts-counter {
  margin: 0.5rem 0 1rem;
}

.attempts-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #334155;
}

.attempts-icon {
  font-size: 1rem;
}

.quiz-final-score-message {
  margin-top: 1.5rem;
}

.quiz-no-attempts {
  font-size: 0.95rem;
  color: #64748b;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

/* ── Progress Dashboard ────────────────────────────────────── */
.progress-total-points {
  text-align: center;
  margin-bottom: 2rem;
}

.progress-points-card {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 3rem;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.25);
}

.progress-points-value {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
}

.progress-points-label {
  font-size: 0.9rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

.progress-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: #64748b;
}

.progress-empty p {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

.progress-course-card {
  background: #fff;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.progress-course-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.progress-course-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1a1a2e;
}

.progress-course-points {
  font-weight: 600;
  color: #2563eb;
  font-size: 0.95rem;
}

.progress-bar-wrap {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-bar {
  height: 100%;
  background: #2563eb;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.progress-course-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: #64748b;
  margin-bottom: 0.75rem;
}

.progress-quiz-list {
  border-top: 1px solid #f1f5f9;
  padding-top: 0.75rem;
}

.progress-quiz-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f8fafc;
  font-size: 0.875rem;
}

.progress-quiz-row:last-child {
  border-bottom: none;
}

.progress-quiz-name {
  flex: 1;
  font-weight: 600;
  color: #334155;
}

.progress-quiz-stat {
  color: #64748b;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .progress-points-card {
    padding: 1.25rem 2rem;
  }

  .progress-points-value {
    font-size: 2rem;
  }

  .progress-quiz-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .progress-quiz-name {
    width: 100%;
  }
}

/* ── Select Elements ───────────────────────────────────────── */
select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  background: #fff;
}

select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

select:disabled {
  opacity: 0.5;
  cursor: default;
}

/* ── Tab Content Panels ────────────────────────────────────── */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ── Courses Sidebar Tree Layout ───────────────────────────── */

.courses-welcome {
  text-align: center;
  padding: 2rem 2rem 1rem;
  color: #64748b;
}

.courses-welcome h2 {
  color: #0f172a;
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 8px;
}

.courses-welcome p {
  font-size: 14px;
}

/* Student Course Cards */
.student-course-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
  padding: 0 2rem 2rem;
}

.student-course-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, border-color 0.2s;
}

.student-course-card:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.student-course-card-icon {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.student-course-card-icon .course-icon-img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 6px;
}

/* Course icon image (sidebar + cards) */
img.course-icon-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  vertical-align: middle;
  border-radius: 4px;
}

.student-course-card-info {
  flex: 1;
  min-width: 0;
}

.student-course-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0 0 4px;
}

.student-course-card-meta {
  font-size: 0.82rem;
  color: #64748b;
  margin: 0 0 10px;
}

.student-course-card-progress {
  display: flex;
  align-items: center;
  gap: 8px;
}

.student-course-card-progress .progress-bar {
  flex: 1;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.student-course-card-progress .progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 3px;
  transition: width 0.3s;
}

.student-course-card-progress .progress-text {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
}

.student-progress-link-wrap {
  text-align: center;
  padding: 1.5rem 2rem;
}

/* ── Student Dashboard (New Design) ──────────────────────── */
.dashboard-container {
  padding: 2rem;
}

.dashboard-greeting h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 4px;
}

.dashboard-greeting p {
  font-size: 0.9rem;
  color: #64748b;
  margin: 0 0 1.5rem;
}

body.dark-mode .dashboard-greeting h2 {
  color: #f1f5f9;
}

body.dark-mode .dashboard-greeting p {
  color: #94a3b8;
}

body.dark-mode .dashboard-courses-header h3 {
  color: #f1f5f9;
}

/* Stats cards row */
.dashboard-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.dashboard-stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.dashboard-stat-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.dashboard-stat-label {
  font-size: 0.82rem;
  color: #64748b;
  margin-top: 4px;
}

/* Courses header */
.dashboard-courses-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.dashboard-courses-header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

/* Course grid */
.dashboard-course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.dashboard-course-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashboard-course-card:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
}

.dashboard-course-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.dashboard-course-icon {
  font-size: 1.75rem;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  border-radius: 10px;
}

.dashboard-course-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
}

.dashboard-course-status.not-started {
  background: #f1f5f9;
  color: #64748b;
}

.dashboard-course-status.in-progress {
  background: #eff6ff;
  color: #2563eb;
}

.dashboard-course-status.completed {
  background: #f0fdf4;
  color: #16a34a;
}

.dashboard-course-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}

.dashboard-course-meta {
  font-size: 0.8rem;
  color: #64748b;
  display: flex;
  gap: 12px;
}

.dashboard-course-progress {
  margin-top: auto;
}

.dashboard-progress-bar {
  height: 5px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.dashboard-progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 3px;
  transition: width 0.3s;
}

.dashboard-progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #94a3b8;
  margin-top: 4px;
}

.dashboard-course-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid #f1f5f9;
}

.dashboard-course-start {
  font-size: 0.82rem;
  font-weight: 600;
  color: #2563eb;
}

@media (max-width: 768px) {
  .dashboard-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-course-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-container {
    padding: 1rem;
  }
}

.student-progress-link {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  color: #2563eb;
  font-weight: 500;
  font-size: 0.95rem;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s;
}

.student-progress-link:hover {
  background: #eff6ff;
  border-color: #2563eb;
}

/* Progress Slide Panel */
.progress-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 60%;
  max-width: 700px;
  height: 100vh;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

.progress-panel.open {
  transform: translateX(0);
}

.progress-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  background: #fff;
}

.progress-panel-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: #0f172a;
}

.progress-panel-content {
  padding: 1.25rem;
  background: #f8fafc;
}

.progress-total-points {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  text-align: center;
  padding: 1rem 0 1.5rem;
}

.progress-panel-courses {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.progress-panel-course {
  padding: 1rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.progress-panel-course-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  font-size: 0.92rem;
  color: #0f172a;
  margin-bottom: 4px;
  cursor: pointer;
  user-select: none;
}

.progress-panel-course-header:hover {
  color: #2563eb;
}

.progress-toggle-arrow {
  display: inline-block;
  font-size: 0.7rem;
  transition: transform 0.2s;
  margin-right: 4px;
}

.progress-panel-course.collapsed .progress-toggle-arrow {
  transform: rotate(-90deg);
}

.progress-panel-course.collapsed .progress-panel-course-body {
  display: none;
}

.progress-panel-points {
  font-size: 0.82rem;
  color: #2563eb;
  font-weight: 600;
}

.progress-panel-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #64748b;
}

.progress-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  margin-top: 12px;
  margin-bottom: 6px;
  padding-left: 4px;
}

.progress-lesson-group {
  margin-top: 10px;
}

.progress-lesson-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 4px;
  padding-left: 2px;
}

.progress-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 12px;
  border-left: 2px solid #e2e8f0;
  margin-left: 6px;
}

.progress-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
}

.progress-item small {
  color: #94a3b8;
  font-weight: 500;
  margin-right: 4px;
}

.progress-item.done {
  background: transparent;
  color: #166534;
}

.progress-item.failed {
  background: transparent;
  color: #dc2626;
}

.progress-item.pending {
  background: transparent;
  color: #475569;
}

.progress-item-pts {
  font-weight: 500;
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
}

.progress-course-summary {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid #e2e8f0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  text-align: right;
}

/* Tree nodes */
.tree-course {
  margin-bottom: 0.25rem;
}

.tree-course > .tree-children {
  border-left: 2px solid #e2e8f0;
  margin-left: 1.2rem;
  padding-left: 0.8rem;
}

.tree-course-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 0.5rem;
  margin-bottom: 6px;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid #e0e7ff;
  background: linear-gradient(90deg, #ecfeff, #f5f3ff);
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a1a2e;
  transition: background 0.15s, border-color 0.15s;
}

.tree-course-header:hover,
.tree-course-header.expanded {
  background: linear-gradient(90deg, #cffafe, #ede9fe);
}

.tree-course-header.expanded {
  color: #2563eb;
  border-color: #c7d2fe;
}

/* Expand/collapse toggle: brand-gradient circle with a drawn +/−. The +/−
   text sidebar.js writes stays in the DOM but is hidden (font-size: 0); the
   icon is drawn from the .is-open class it toggles alongside. */
.tree-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 0;
  user-select: none;
  cursor: pointer;
  background: linear-gradient(135deg, #06b6d4, #7c3aed);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.tree-toggle::before,
.tree-toggle::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  background: #fff;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, background 0.2s ease;
}

.tree-toggle::before { width: 9px; height: 2px; }
.tree-toggle::after  { width: 2px; height: 9px; }

.tree-toggle.is-open {
  background: #e2e8f0;
  box-shadow: none;
}

.tree-toggle.is-open::before { background: #7c3aed; }
.tree-toggle.is-open::after  { transform: translate(-50%, -50%) scaleY(0); }

/* Lesson level: lighter outlined version so course rows stay the focal point */
.tree-toggle-sm {
  width: 16px;
  height: 16px;
  background: #fff;
  border: 1.5px solid #a78bfa;
  box-shadow: none;
}

.tree-toggle-sm::before { width: 7px; height: 1.5px; background: #7c3aed; }
.tree-toggle-sm::after  { width: 1.5px; height: 7px; background: #7c3aed; }

.tree-toggle-sm.is-open {
  background: #ede9fe;
  border-color: #ede9fe;
}

body.dark-mode .tree-toggle.is-open { background: transparent; box-shadow: inset 0 0 0 1.5px #a78bfa; }
body.dark-mode .tree-toggle.is-open::before { background: #c4b5fd; }
body.dark-mode .tree-toggle-sm { background: transparent; border-color: #8b5cf6; }
body.dark-mode .tree-toggle-sm::before,
body.dark-mode .tree-toggle-sm::after { background: #c4b5fd; }
body.dark-mode .tree-toggle-sm.is-open { background: #3b2f63; border-color: #3b2f63; }

@media (prefers-reduced-motion: reduce) {
  .tree-toggle, .tree-toggle::before, .tree-toggle::after { transition: none; }
}

.tree-children {
  padding-left: 2rem;
}

.tree-lesson {
  margin-bottom: 1px;
}

.tree-lesson-header {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.5rem;
  border-radius: 4px;
  font-size: 0.88rem;
  transition: background 0.15s;
  position: relative;
  overflow: hidden;
}

.tree-lesson-header:hover {
  background: #f8fafc;
}

.tree-lesson-link {
  color: #334155;
  text-decoration: none;
  flex: 1;
}

.tree-lesson-link:hover {
  color: #2563eb;
  text-decoration: underline;
}

.tree-leaf-dot {
  color: #cbd5e1;
  font-size: 0.7rem;
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.tree-item {
  padding: 0.3rem 0.5rem 0.3rem 1.5rem;
  font-size: 0.82rem;
  position: relative;
  overflow: hidden;
}

.tree-item a {
  color: #64748b;
  text-decoration: none;
}

.tree-item a:hover {
  color: #2563eb;
  text-decoration: underline;
}

/* ── Tree badges for Quiz/Lab/Homework ─────────────────────── */
.tree-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  vertical-align: middle;
  margin-right: 4px;
}

.tree-badge-quiz {
  background: #dbeafe;
  color: #1e40af;
}

.tree-badge-lab {
  background: #d1fae5;
  color: #065f46;
}

.tree-badge-hw {
  background: #fef3c7;
  color: #92400e;
}

.tree-badge-read {
  background: #e0f2fe;
  color: #0369a1;
}

/* ── Dark Mode — Tree Badges ──────────────────────────────── */
body.dark-mode .tree-badge-read {
  background: #0c4a6e;
  color: #7dd3fc;
}

body.dark-mode .tree-badge-quiz {
  background: #1e3a5f;
  color: #93c5fd;
}

body.dark-mode .tree-badge-lab {
  background: #1a3a2a;
  color: #86efac;
}

body.dark-mode .tree-badge-hw {
  background: #3b2f1a;
  color: #fcd34d;
}

.tree-empty-item {
  padding: 0.4rem 0.5rem;
  font-size: 0.85rem;
  color: #94a3b8;
  font-style: italic;
}

.tree-loading,
.tree-empty {
  color: #94a3b8;
  font-size: 0.9rem;
  padding: 0.5rem;
}

@media (max-width: 768px) {
  .courses-layout {
    flex-direction: column;
  }

  .courses-sidebar {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    max-height: 50vh;
  }

  .courses-main {
    padding: 1rem;
  }
}

/* ── Sidebar Toggle & Collapse ─────────────────────────────── */
.courses-layout {
  display: flex;
  min-height: calc(100vh - 52px);
}

.courses-sidebar {
  width: 280px;
  min-width: 280px;
  background: #f8fafc;
  border-right: 1px solid #e2e8f0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.3s ease, min-width 0.3s ease;
  position: sticky;
  top: 48px;
  height: calc(100vh - 48px);
  align-self: flex-start;
}

.courses-sidebar h2 {
  display: none; /* replaced by sidebar-header */
}

.sidebar-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* Student sidebar only -- admin.html's dark .sidebar reuses .sidebar-header */
.courses-sidebar .sidebar-header {
  border-bottom: none;
}

.sidebar-toggle-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  flex-shrink: 0;
  transition: background 0.15s;
}

.sidebar-search {
  padding: 12px 14px;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.sidebar-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.85rem;
  background: #fff;
  color: #1a1a2e;
}

.sidebar-search-input:focus {
  outline: none;
  border-color: #6366f1;
  background: #fff;
}

.courses-sidebar.collapsed .sidebar-search {
  display: none;
}

.search-hidden {
  display: none !important;
}

.sidebar-toggle-btn:hover {
  background: #e2e8f0;
}

.sidebar-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1a1a2e;
  white-space: nowrap;
}

/* Collapsed state */
.courses-sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}

.courses-sidebar.collapsed .sidebar-title {
  display: none;
}

/* Sidebar Account Section (bottom) */
.sidebar-account-section {
  margin-top: auto;
  padding: 14px 14px 16px;
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.5px;
  padding-left: 4px;
}

.sidebar-account-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: #334155;
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid #e0e7ff;
  background: linear-gradient(90deg, #ecfeff, #f5f3ff);
  transition: background 0.15s, border-color 0.15s;
}

.sidebar-account-link:hover {
  background: linear-gradient(90deg, #cffafe, #ede9fe);
  border-color: #c7d2fe;
}

.sidebar-account-icon {
  font-size: 0.9rem;
}

.sidebar-signout-link {
  color: #dc2626;
  background: #fef2f2;
  border-color: #fecaca;
}

.sidebar-signout-link:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Settings page container */
.settings-container {
  max-width: 600px;
  padding: 2rem;
}

.settings-container h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 1.5rem;
}

.settings-section-desc {
  font-size: 0.82rem;
  color: #64748b;
  margin: -4px 0 12px;
}

.setting-hint {
  font-size: 0.75rem;
  color: #94a3b8;
  margin: 2px 0 0;
}

/* ── Live Classes Page ────────────────────────────────────── */
.classes-header {
  padding: 2rem 2rem 0.5rem;
}

.classes-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 4px;
}

.classes-subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin: 0;
}

.classes-empty {
  text-align: center;
  padding: 3rem 2rem;
  color: #64748b;
}

.classes-empty-hint {
  font-size: 0.85rem;
  color: #94a3b8;
  margin-top: 4px;
}

.courses-sidebar.collapsed .sidebar-account-section {
  padding: 8px 4px;
}

.courses-sidebar.collapsed .sidebar-section-title {
  display: none;
}

.courses-sidebar.collapsed .sidebar-account-link {
  justify-content: center;
  padding: 8px;
  font-size: 0;
}

.courses-sidebar.collapsed .sidebar-account-icon {
  font-size: 1.1rem;
}

.courses-sidebar.collapsed #courses-tree {
  padding: 12px 4px 0;
}

#courses-tree {
  padding: 0 12px 12px;
}

/* In collapsed mode: hide tree text, toggles, children — show only course icons */
.courses-sidebar.collapsed .tree-toggle,
.courses-sidebar.collapsed .tree-course-name,
.courses-sidebar.collapsed .tree-children,
.courses-sidebar.collapsed .tree-loading,
.courses-sidebar.collapsed .tree-empty,
.courses-sidebar.collapsed .tree-lesson,
.courses-sidebar.collapsed .tree-empty-item {
  display: none !important;
}

.courses-sidebar.collapsed .tree-course-header {
  justify-content: center;
  padding: 10px 0;
}

.courses-sidebar.collapsed .tree-course-icon {
  font-size: 1.4rem;
}

.courses-sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 12px 8px;
}

/* Course icon styling */
.tree-course-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
  cursor: pointer;
}

.courses-main {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  background: #f8fafc;
}

/* ── Active item highlighting ─────────────────────────────── */
/* Default (lesson leaf / "Read" rows): sky-blue accent, matching .tree-badge-read */
.tree-active {
  background: #eff6ff;
  border-radius: 4px;
  animation: tree-active-glow 0.6s ease-out;
}

.tree-active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 3px;
  border-radius: 2px;
  background: #0369a1;
  animation: tree-active-bar-in 0.3s ease-out both;
}

.tree-link-active {
  color: #2563eb !important;
  font-weight: 600;
}

/* Per-type accent colors, matching the Quiz/Lab/HW badge palette */
.tree-item-quiz.tree-active {
  background: #eff6ff;
}
.tree-item-quiz.tree-active::before {
  background: #1e40af;
}

.tree-item-lab.tree-active {
  background: #ecfdf5;
}
.tree-item-lab.tree-active::before {
  background: #065f46;
}

.tree-item-homework.tree-active {
  background: #fffbeb;
}
.tree-item-homework.tree-active::before {
  background: #92400e;
}

.tree-item-read.tree-active {
  background: #f0f9ff;
}
.tree-item-read.tree-active::before {
  background: #0369a1;
}

@keyframes tree-active-bar-in {
  from {
    transform: translateX(-4px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes tree-active-glow {
  0% {
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tree-active,
  .tree-active::before {
    animation: none;
  }
}

@media (max-width: 768px) {
  .courses-layout {
    flex-direction: column;
  }

  .courses-sidebar {
    width: 100% !important;
    min-width: unset !important;
    height: auto;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid #e2e8f0;
    position: static;
    align-self: auto;
  }

  .courses-sidebar.collapsed {
    width: 100% !important;
    min-width: unset !important;
    max-height: 56px;
    overflow: hidden;
  }

  .courses-main {
    padding: 1rem;
  }
}

/* ── Lab & Homework Components ─────────────────────────────── */

/* Lab instructions / homework prompt content block */
.lab-instructions-content,
.homework-prompt-content {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  line-height: 1.7;
  margin-bottom: 1.5rem;
  white-space: pre-wrap;
  font-size: 0.95rem;
  color: #334155;
}

/* Dark mode — Lab & Homework content blocks */
body.dark-mode .lab-instructions-content,
body.dark-mode .homework-prompt-content {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

body.dark-mode .lab-instructions-content h1,
body.dark-mode .lab-instructions-content h2,
body.dark-mode .lab-instructions-content h3,
body.dark-mode .homework-prompt-content h1,
body.dark-mode .homework-prompt-content h2,
body.dark-mode .homework-prompt-content h3 {
  color: #f1f5f9;
}

body.dark-mode .lab-instructions-content code,
body.dark-mode .homework-prompt-content code {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .lab-instructions-content pre,
body.dark-mode .homework-prompt-content pre {
  background: #0f172a;
}

/* Submission status card */
.submission-status-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

body.dark-mode .submission-status-card {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

.submission-status-card .status-badge {
  font-size: 0.82rem;
}

.submission-status-card .grade-display {
  font-weight: 700;
  font-size: 1.1rem;
  color: #1a1a2e;
}

body.dark-mode .submission-status-card .grade-display {
  color: #f1f5f9;
}

/* Homework Result Container */
.hw-result-container {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 500px;
  margin: 0 auto;
  background: #f8fafc;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

.hw-result-ring-wrapper {
  position: relative;
  display: block;
  width: 140px;
  height: 140px;
  margin: 0 auto 1rem;
}

.hw-result-ring {
  display: block;
}

.hw-result-ring-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.hw-result-score {
  font-size: 1.8rem;
  font-weight: 700;
  color: #0f172a;
}

.hw-result-badge {
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 5px 18px;
  border-radius: 20px;
  margin-bottom: 0.75rem;
}

.hw-result-badge.passed {
  color: #166534;
  border: 1.5px solid #86efac;
  background: #f0fdf4;
}

.hw-result-badge.failed {
  color: #991b1b;
  border: 1.5px solid #fca5a5;
  background: #fef2f2;
}

.hw-result-points {
  color: #64748b;
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

.hw-result-note {
  color: #94a3b8;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}

.hw-result-resubmit {
  margin-top: 1.25rem;
}

.hw-result-sublabel {
  display: block;
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

.hw-result-message {
  font-size: 0.9rem;
  margin: 0.25rem 0 1.25rem;
  color: #64748b;
}

.hw-result-message.passed { color: #16a34a; }
.hw-result-message.failed { color: #64748b; }

/* Homework progress bar */
.hw-result-progress-container {
  max-width: 400px;
  margin: 0 auto 1.25rem;
  width: 100%;
}

.hw-result-progress-bar {
  position: relative;
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: visible;
}

.hw-result-progress-fill {
  height: 100%;
  border-radius: 4px;
  animation: bar-fill 0.8s ease-out forwards;
}

.hw-result-progress-fill.passed { background: #16a34a; }
.hw-result-progress-fill.failed { background: #dc2626; }

.hw-result-progress-mark {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  background: #64748b;
  border-radius: 1px;
  transform: translateX(-50%);
}

.hw-result-progress-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.75rem;
  color: #64748b;
}

.hw-result-pass-label {
  color: #16a34a;
  font-weight: 500;
}

/* Homework Attempt History (quiz-style) */
.hw-history-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}

.hw-history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hw-history-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.hw-history-item:hover {
  border-color: #cbd5e1;
}

.hw-history-item.best {
  background: #f0fdf4;
  border-color: #86efac;
}

.hw-history-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 0.88rem;
  color: #334155;
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.hw-history-summary::-webkit-details-marker {
  display: none;
}

.hw-history-summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hw-history-summary-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hw-history-icon {
  font-size: 0.9rem;
}

.hw-history-attempt-num {
  font-weight: 600;
  color: #0f172a;
}

.hw-history-status {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

.hw-attempt-passed {
  color: #166534;
  background: #dcfce7;
}

.hw-attempt-failed {
  color: #991b1b;
  background: #fee2e2;
}

.hw-history-mini-bar {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

.hw-history-mini-fill {
  display: block;
  height: 100%;
  border-radius: 3px;
}

.hw-history-pct {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0f172a;
  min-width: 36px;
  text-align: right;
}

.hw-history-chevron {
  font-size: 0.7rem;
  color: #94a3b8;
  transition: transform 0.2s;
}

.hw-history-item[open] .hw-history-chevron {
  transform: rotate(180deg);
}

.hw-history-body {
  padding: 12px 16px 16px;
  border-top: 1px solid #f1f5f9;
  background: #f8fafc;
}

.hw-history-date {
  font-size: 0.8rem;
  color: #64748b;
  margin-bottom: 10px;
}

.hw-history-feedback {
  margin-top: 8px;
}

.hw-history-feedback-title {
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  margin-bottom: 6px;
}

.hw-history-feedback-list {
  margin: 0;
  padding-left: 1.2rem;
  list-style: disc;
}

.hw-history-feedback-list li {
  font-size: 0.82rem;
  color: #475569;
  line-height: 1.5;
  margin-bottom: 4px;
}

/* AI Feedback Container */
.ai-feedback-container {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  margin-top: 1.5rem;
  width: 100%;
  max-width: 600px;
}

.ai-feedback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.ai-feedback-status {
  font-size: 0.85rem;
  color: #64748b;
}

.ai-feedback-grade {
  font-size: 0.9rem;
  color: #0f172a;
}

.ai-feedback-section {
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
}

.ai-feedback-section:last-child {
  border-bottom: none;
}

.ai-feedback-section.intro {
  background: #f8fafc;
  color: #475569;
  font-size: 0.88rem;
}

.ai-feedback-section.question {
  border-left: 3px solid #3b82f6;
}

.ai-feedback-section.overall {
  border-left: 3px solid #f59e0b;
  background: #fffbeb;
}

.ai-feedback-section.recommendation {
  border-left: 3px solid #16a34a;
  background: #f0fdf4;
}

.ai-feedback-section-title {
  font-weight: 600;
  font-size: 0.88rem;
  color: #0f172a;
  margin-bottom: 6px;
}

.ai-feedback-section-body {
  font-size: 0.85rem;
  color: #334155;
  line-height: 1.6;
}

/* Grading panel styles */
.grading-details {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

.grading-content {
  margin-bottom: 1rem;
}

.grading-content > div {
  background: #f8fafc;
  border-radius: 6px;
  padding: 1rem;
  border: 1px solid #f1f5f9;
}

.grading-content h4 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.grading-content p,
.grading-content pre {
  margin: 0;
  font-size: 0.9rem;
  white-space: pre-wrap;
  color: #334155;
}

.grading-action {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
}

.grading-action input[type="number"] {
  width: 80px;
  padding: 0.4rem 0.5rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 0.9rem;
}

.grading-action .btn-primary {
  padding: 0.4rem 1rem;
  font-size: 0.9rem;
}

/* Sidebar tree items for labs and homework */
.tree-item-lab a,
.tree-item-homework a {
  color: #64748b;
  text-decoration: none;
}

.tree-item-lab a:hover,
.tree-item-homework a:hover {
  color: #2563eb;
  text-decoration: underline;
}

/* Lesson page lab/homework button container */
.lab-hw-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.lab-hw-buttons a {
  font-size: 0.9rem;
}

/* ── Screenshot Upload Area ────────────────────────────────── */
.screenshot-upload-area {
  border: 2px dashed #e2e8f0;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.screenshot-upload-area:hover {
  border-color: #2563eb;
  background: #f8fafc;
}

.screenshot-upload-area.drag-over {
  border-color: #2563eb;
  background: #eff6ff;
}

/* ── Dark Mode — Lab & Homework Submit Sections ───────────── */
body.dark-mode #lab-submit-section textarea,
body.dark-mode #homework-submit-section textarea {
  background: #1e293b;
  color: #e2e8f0;
  border-color: #334155;
}

body.dark-mode #lab-submit-section label,
body.dark-mode #homework-submit-section label {
  color: #e2e8f0;
}

body.dark-mode .screenshot-upload-area {
  border-color: #475569;
  background: #1e293b;
}

body.dark-mode .screenshot-upload-area:hover {
  border-color: #3b82f6;
  background: #1e3a5f;
}

@media (max-width: 768px) {
  .grading-action {
    flex-wrap: wrap;
  }

  .lab-hw-buttons {
    flex-direction: column;
  }

  .lab-hw-buttons a {
    text-align: center;
  }
}

/* ── AI Content Generation & Grading ──────────────────────── */

/* Container for the "Generate with AI" controls in editors */
.ai-generate-section {
  margin-bottom: 1rem;
}

/* 🤖 AI Graded badge (blue-purple, white text, rounded pill) */
.ai-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
}

/* ⏳ Pending badge (amber/yellow, rounded pill) */
.pending-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

/* AI feedback text panel shown to students after grading */
.ai-feedback-panel {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.6;
}

/* AI feedback card in the admin grading panel */
.ai-feedback-card {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #1e40af;
  line-height: 1.6;
}

/* ── Class Dashboard ──────────────────────────────────────── */

/* Wider container for class section */
#tab-classes .container,
#tab-classes {
  max-width: 1400px;
}

/* Filter bar */
.filters {
  display: flex;
  gap: 12px;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  background: #fff;
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  margin-bottom: 0;
}

.filter-group select {
  width: auto;
  padding: 6px 10px;
  font-size: 0.875rem;
}

/* Metric cards grid */
.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  border-left: 4px solid #3b82f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.metric-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.12);
}

.metric-card.orange {
  border-left-color: #f59e0b;
}

.metric-card.green {
  border-left-color: #10b981;
}

.metric-card.purple {
  border-left-color: #8b5cf6;
}

.metric-label {
  font-size: 0.75rem;
  color: #64748b;
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 32px;
  font-weight: 700;
  color: #0f172a;
}

/* Class card grid */
.classes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* Individual class card */
.class-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  /* border-left set inline by JS: 4px solid color */
}

.class-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  border-color: #3b82f6;
}

/* Class card header */
.class-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.class-name {
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a2e;
  flex: 1;
  margin-right: 8px;
}

/* Status badge (pill) — shared by cards and table */
.class-status {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.class-status.status-active {
  background: #d1fae5;
  color: #065f46;
}

.status-upcoming {
  background: #dbeafe;
  color: #1e40af;
}

.status-completed {
  background: #e2e8f0;
  color: #475569;
}

.status-expired {
  background: #fee2e2;
  color: #991b1b;
}

/* Class info rows */
.class-info {
  font-size: 0.85rem;
  margin-bottom: 12px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  padding: 3px 0;
}

.info-label {
  color: #94a3b8;
  font-weight: 500;
}

.info-value {
  font-weight: 600;
  color: #1a1a2e;
}

/* Class progress bar (scoped to avoid conflict with existing .progress-bar) */
.class-card .progress-bar,
.progress-item .progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 12px;
}

.class-card .progress-fill,
.progress-item .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* 2×2 student breakdown grid */
.student-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  font-size: 0.78rem;
  margin-bottom: 12px;
}

.breakdown-item {
  padding: 8px;
  background: #f8fafc;
  border-radius: 6px;
  text-align: center;
  border: 1px solid #e2e8f0;
}

.breakdown-label {
  color: #64748b;
  display: block;
  margin-bottom: 3px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.breakdown-count {
  font-weight: 700;
  font-size: 1rem;
  color: #1a1a2e;
}

/* Class card action buttons */
.class-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
}

/* Summary table section */
.table-section {
  background: #fff;
  border-radius: 12px;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  margin-bottom: 30px;
  overflow-x: auto;
}

.table-section .table-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  padding: 20px 30px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 0;
}

.table-section table {
  width: 100%;
  border-collapse: collapse;
}

.table-section thead {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
}

.table-section th {
  padding: 16px 30px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table-section td {
  padding: 16px 30px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
  color: #334155;
}

.table-section tr:hover {
  background: #f8fafc;
}

/* ── Class Detail View ────────────────────────────────────── */

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #2563eb;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 20px;
  cursor: pointer;
}

.back-link:hover {
  color: #1e40af;
}

/* Class header card */
.class-header-card {
  background: white;
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border-left: 4px solid #2563eb;
}

.class-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.class-title {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
}

.class-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 25px;
  margin-bottom: 20px;
}

.info-item { display: flex; flex-direction: column; }

.info-label {
  font-size: 12px;
  color: #718096;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  margin-bottom: 6px;
}

.info-value {
  font-size: 16px;
  font-weight: 600;
  color: #0f172a;
}

.class-description-text {
  font-size: 14px;
  color: #475569;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  margin-top: 20px;
}

/* Two-column: Enroll + Progress */
.class-main-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  margin-bottom: 30px;
}

/* Enroll section */
.class-enroll-section {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.section-title-icon {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 20px 0;
}

.class-enroll-section .form-group label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #2d3748;
}

.class-enroll-section .form-input {
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
}

.class-enroll-section .form-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.class-enroll-section textarea.form-input {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  min-height: 80px;
}

.enroll-button-group {
  display: flex;
  gap: 12px;
}

.enroll-btn {
  flex: 1;
  text-align: center;
  justify-content: center;
  padding: 12px 20px;
}

/* Progress card */
.class-progress-card {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cd-progress-item { margin-bottom: 28px; }
.cd-progress-item:last-child { margin-bottom: 0; }

.cd-progress-label {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}

.cd-progress-stat {
  font-size: 12px;
  color: #718096;
  font-weight: 500;
}

.cd-progress-bar {
  height: 8px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
}

.cd-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #2563eb 0%, #1e40af 100%);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.cd-progress-fill.medium {
  background: linear-gradient(90deg, #f59e0b 0%, #d97706 100%);
}

.cd-progress-fill.low {
  background: linear-gradient(90deg, #ef4444 0%, #dc2626 100%);
}

/* Enrolled students — full width */
.enrolled-section {
  background: white;
  border-radius: 12px;
  padding: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  border: 2px solid #e2e8f0;
}

.enrolled-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.enrolled-header .section-title-icon { margin-bottom: 0; }

.enrolled-count {
  background: #dbeafe;
  color: #1e40af;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 13px;
}

.students-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 15px;
}

.student-card {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  transition: all 0.3s ease;
}

.student-card:hover {
  border-color: #2563eb;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.1);
}

.student-card-expired { opacity: 0.6; }

.student-email {
  font-size: 13px;
  color: #0f172a;
  font-weight: 600;
  margin-bottom: 4px;
  word-break: break-all;
}

.student-meta {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 8px;
}

.student-action-link {
  font-size: 12px;
  color: #2563eb;
  cursor: pointer;
  font-weight: 600;
}

.student-action-link:hover {
  color: #1e40af;
  text-decoration: underline;
}

.empty-state-text {
  text-align: center;
  padding: 40px 20px;
  color: #718096;
  font-size: 14px;
}

/* Course assignment grid on class detail */
.class-detail-course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 10px;
}

.class-detail-course-item {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s;
}

.class-detail-course-item:hover {
  border-color: #2563eb;
  background: #f8fafc;
}

/* Checkbox + icon + name (+ checkmark) on one line -- the Re-sync button
   (when present) is a separate flex child stacked below, so a long course
   name plus the button can never overflow this item's own box into the
   next course's grid cell. */
.class-detail-course-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.class-detail-course-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.class-detail-course-item input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
}

.class-detail-course-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.class-detail-course-check {
  color: #10b981;
  font-weight: 700;
  margin-left: auto;
  flex-shrink: 0;
}

.class-detail-course-resync {
  align-self: flex-start;
}

@media (max-width: 1024px) {
  .class-main-grid { grid-template-columns: 1fr; }
  .class-info-grid { grid-template-columns: repeat(2, 1fr); }
  .students-card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 768px) {
  .class-info-grid { grid-template-columns: 1fr; }
  .enroll-button-group { flex-direction: column; }
  .students-card-grid { grid-template-columns: 1fr; }
}

/* Students table section (class-filtered student view) */
.class-students-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  overflow-x: auto;
}

.class-students-section h3 {
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}

/* Progress section */
.class-progress-section {
  background: #fff;
  border-radius: 12px;
  padding: 1.25rem;
  margin: 1rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.class-progress-section h3 {
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}

.progress-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.progress-item {
  padding: 1rem;
  background: #f8fafc;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.progress-item-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1a2e;
  margin-bottom: 6px;
}

.progress-item-detail {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 4px;
}

/* Create/Edit class form container */
.class-form-container {
  background: #fff;
  border-radius: 12px;
  padding: 30px;
  margin: 1rem 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  max-width: 600px;
}

.class-form-container h2 {
  margin-bottom: 1rem;
  color: #1a1a2e;
}

/* Course checkbox list for class assignment */
.course-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.course-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: normal;
  font-size: 0.9rem;
  transition: background 0.15s;
}

.course-checkbox-item:hover {
  background: #f8fafc;
}

.course-checkbox-item input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
}

/* Season name preview */
.season-preview {
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-size: 0.95rem;
  color: #1a1a2e;
  font-weight: 600;
}

/* ── Class Responsive Breakpoints ─────────────────────────── */

@media (max-width: 768px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .classes-grid {
    grid-template-columns: 1fr;
  }

  .filters {
    flex-direction: column;
  }

  .filter-group {
    width: 100%;
  }

  .filter-group select {
    width: 100%;
  }

  .progress-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: 1fr;
  }

  .metric-value {
    font-size: 1.5rem;
  }

  .class-header {
    flex-direction: column;
    gap: 6px;
  }

  .class-status {
    align-self: flex-start;
  }

  .student-breakdown {
    grid-template-columns: 1fr;
  }
}

/* ── V3 Design System Additions ───────────────────────────── */

/* Font family override for admin layout */
body.admin-layout {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #f8fafc;
  color: #1e293b;
}

/* Section headers */
body.admin-layout .section-title {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
}

body.admin-layout .section-subtitle {
  font-size: 13px;
  color: #64748b;
  margin-top: 4px;
}

/* V3 Badge variants */
.badge-active {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #d1fae5;
  color: #065f46;
}

.badge-pending {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #fef3c7;
  color: #92400e;
}

.badge-completed {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: #dbeafe;
  color: #0c2d6b;
}

/* Form section (v3 pattern) */
body.admin-layout .form-section {
  background: white;
  border-radius: 12px;
  padding: 30px;
  margin-bottom: 30px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Form row 2-column layout */
body.admin-layout .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* Admin form group label styling */
body.admin-layout .form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #1e293b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Admin form inputs */
body.admin-layout .form-group input,
body.admin-layout .form-group select,
body.admin-layout .form-group textarea {
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  transition: all 0.3s ease;
}

body.admin-layout .form-group input:focus,
body.admin-layout .form-group select:focus,
body.admin-layout .form-group textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Table header area (v3 pattern) */
body.admin-layout .table-header {
  padding: 20px 30px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

body.admin-layout .table-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
}

/* Search box in table header */
body.admin-layout .search-box {
  padding: 10px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
  min-width: 250px;
  transition: all 0.3s ease;
}

body.admin-layout .search-box:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Card footer (v3 pattern) */
body.admin-layout .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid #e2e8f0;
}

body.admin-layout .card-meta {
  font-size: 12px;
  color: #94a3b8;
}

/* Stat label (v3 pattern) */
body.admin-layout .metric-label,
body.admin-layout .stat-label {
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  font-weight: 600;
}

/* Secondary button (v3 pattern) */
body.admin-layout .btn-secondary {
  background: #f1f5f9;
  color: #475569;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

body.admin-layout .btn-secondary:hover {
  background: #e2e8f0;
}

/* Progress bar gradient (v3 pattern) */
body.admin-layout .progress-bar {
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
}

body.admin-layout .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #2563eb 100%);
}

/* Text muted utility */
body.admin-layout .text-muted {
  color: #94a3b8;
}

/* Admin h2 headings */
body.admin-layout .tab-content > h2 {
  font-size: 20px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 20px;
}

/* Admin h3 headings */
body.admin-layout .tab-content > h3 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 16px;
}

/* Responsive form-row for admin */
@media (max-width: 768px) {
  body.admin-layout .form-row {
    grid-template-columns: 1fr;
  }
}

/* ── Student Header ───────────────────────────────────────── */

.student-header {
  background: #0f172a;
  padding: 12px 24px;
  border-bottom: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  position: sticky;
  top: 0;
  z-index: 50;
}

.student-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.student-header-class {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 3px 12px;
  white-space: nowrap;
}

@media (max-width: 640px) {
  .student-header-class {
    display: none !important;
  }
}

.student-header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  text-decoration: none;
}

.student-logo-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  border-radius: 6px;
}

.student-header-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.student-header-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #e2e8f0;
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.student-header-link:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
  color: #ffffff;
}

/* Current page, e.g. Leaderboard while on leaderboard.html -- reuses the
   existing aria-current="page" already set in the markup, so this is a
   pure CSS addition, no HTML changes needed anywhere it's used. */
.student-header-link[aria-current="page"] {
  background: rgba(37, 99, 235, 0.28);
  border-color: rgba(37, 99, 235, 0.55);
  color: #ffffff;
}

.student-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  text-decoration: none;
  transition: background 0.2s;
}

.student-header-avatar:hover {
  background: #1d4ed8;
}

.student-header-email {
  font-size: 0.82rem;
  color: #94a3b8;
}

.student-header-signout {
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all 0.15s;
}

.student-header-signout:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

/* ── Student Footer ──────────────────────────────────────── */

.student-footer {
  background: #0f172a;
  color: #94a3b8;
  text-align: center;
  padding: 8px 2rem;
  font-size: 0.72rem;
  border-top: 1px solid #1e293b;
  margin-top: auto;
}

.student-footer p {
  margin: 0;
}

.student-footer a {
  color: #cbd5e1;
  text-decoration: none;
}

.student-footer a:hover {
  color: #ffffff;
}

/* ── Student Content (progress page) ──────────────────────── */

.student-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px;
}

@media (max-width: 768px) {
  .student-header {
    flex-direction: column;
    gap: 10px;
    padding: 12px 16px;
  }

  .student-header-right {
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
  }

  .student-content {
    padding: 20px 16px;
  }
}

/* ── Generic Card Grid (v3 pattern) ───────────────────────── */

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
  cursor: pointer;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
  border-color: #3b82f6;
}

.card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.card .card-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  flex: 1;
}

.card .card-content {
  font-size: 13px;
  color: #64748b;
  line-height: 1.6;
}

.card .card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px solid #e2e8f0;
  font-size: 12px;
  color: #94a3b8;
}

/* ── Grading Tab ──────────────────────────────────────────── */

.grading-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.breadcrumb-link {
  color: #3b82f6;
  text-decoration: none;
  font-weight: 500;
}

.breadcrumb-link:hover {
  text-decoration: underline;
}

.breadcrumb-sep {
  color: #94a3b8;
}

.breadcrumb-current {
  color: #64748b;
  font-weight: 600;
}

/* Grade bar chart */
.grade-chart {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.grade-chart-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grade-chart-label {
  width: 140px;
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  text-align: right;
  flex-shrink: 0;
}

.grade-chart-bar-wrap {
  flex: 1;
  height: 24px;
  background: #f1f5f9;
  border-radius: 6px;
  overflow: hidden;
}

.grade-chart-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.5s ease;
  min-width: 2px;
}

.grade-chart-value {
  width: 110px;
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  flex-shrink: 0;
}

.grading-summary-section {
  margin-bottom: 20px;
}

/* Stats grid for grading (reuse existing but with v3 colors) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  border-left: 4px solid #3b82f6;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.stat-card.orange { border-left-color: #f59e0b; }
.stat-card.green { border-left-color: #10b981; }
.stat-card.purple { border-left-color: #8b5cf6; }

.stat-label {
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  font-weight: 600;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
}

@media (max-width: 768px) {
  .grade-chart-label {
    width: 80px;
    font-size: 11px;
  }

  .grade-chart-value {
    width: 80px;
    font-size: 11px;
  }

  .grade-chart-bar-wrap {
    height: 18px;
  }
}

/* ── Student Profile ──────────────────────────────────────── */

.profile-container {
  max-width: 1140px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

.profile-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.profile-avatar-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  cursor: pointer;
  border-radius: 50%;
}

.profile-avatar-wrap:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 3px;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  overflow: hidden;
}

.profile-avatar-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.52);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.18s;
  pointer-events: none;
}

.profile-avatar-overlay-icon { font-size: 1rem; line-height: 1; }

.profile-avatar-wrap:hover .profile-avatar-overlay { opacity: 1; }

.avatar-remove-btn {
  margin-top: 6px;
  background: none;
  border: none;
  color: #64748b;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
}

.avatar-remove-btn:hover { color: #ef4444; }

.profile-info h2 {
  margin: 0 0 4px;
  font-size: 1.3rem;
  color: #0f172a;
}

.profile-email {
  margin: 0;
  color: #64748b;
  font-size: 0.9rem;
}

.profile-class {
  margin: 4px 0 0;
  color: #2563eb;
  font-size: 0.85rem;
  font-weight: 500;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e2e8f0;
}

.profile-stat {
  text-align: center;
}

.profile-stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
}

.profile-stat-label {
  font-size: 0.78rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.profile-sections {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
  align-items: start;
}

.profile-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.5rem;
}

.profile-section--wide {
  grid-column: 1 / -1;
}

@media (max-width: 768px) {
  .profile-sections {
    grid-template-columns: 1fr;
  }
}

.profile-section h3 {
  margin: 0 0 1rem;
  font-size: 1rem;
  color: #0f172a;
}

.profile-activity-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-activity-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: #f8fafc;
  border-radius: 6px;
  font-size: 0.85rem;
}

.profile-activity-score {
  color: #64748b;
  font-size: 0.8rem;
}

.profile-empty {
  color: #94a3b8;
  font-size: 0.9rem;
}

.profile-settings {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: 0.9rem;
}

.notification-email-item {
  padding-bottom: 16px;
  margin-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.settings-text-input {
  display: block;
  width: 100%;
  max-width: 320px;
  margin-top: 8px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.88rem;
  color: #1a1a2e;
  box-sizing: border-box;
}

.settings-text-input:focus {
  outline: none;
  border-color: #6366f1;
}

.notification-email-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  max-width: 420px;
}

.notification-email-row .settings-text-input {
  margin-top: 0;
  max-width: none;
  flex: 1;
}

.btn-add-email {
  flex-shrink: 0;
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
  color: #1a1a2e;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-add-email:hover:not(:disabled) {
  background: #eef2ff;
  border-color: #c7d2fe;
}

.btn-add-email:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.notification-email-item .error-message {
  margin: 6px 0 0;
  font-size: 0.82rem;
  min-height: 0;
}

.notification-email-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.notification-email-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px 6px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  font-size: 0.82rem;
  color: #166534;
}

.notification-email-chip button {
  border: none;
  background: none;
  cursor: pointer;
  color: #166534;
  font-size: 1rem;
  line-height: 1;
  padding: 2px;
  border-radius: 50%;
}

.notification-email-chip button:hover {
  background: #bbf7d0;
}

.toggle-switch.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.toggle-switch.disabled .toggle-slider {
  cursor: not-allowed;
}

@media (max-width: 600px) {
  .profile-stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .profile-header {
    flex-direction: column;
    text-align: center;
  }
}

/* ── Achievements Badges ──────────────────────────────────── */

.badges-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.badge-item {
  text-align: center;
  padding: 1rem 0.5rem;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  transition: transform 0.2s;
}

.badge-item.earned {
  background: #f0fdf4;
  border-color: #86efac;
}

.badge-item.locked {
  background: #f8fafc;
  opacity: 0.5;
  filter: grayscale(1);
}

.badge-item.earned:hover {
  transform: translateY(-2px);
}

.badge-icon {
  font-size: 2rem;
  margin-bottom: 6px;
}

.badge-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 2px;
}

.badge-desc {
  font-size: 0.7rem;
  color: #64748b;
}

/* ── Learning Streak ──────────────────────────────────────── */

.streak-summary {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 1rem;
}

.streak-number {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
}

.streak-fire {
  font-size: 1.3rem;
}

.streak-longest {
  font-size: 0.85rem;
  color: #64748b;
}

.streak-week {
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.streak-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  color: #94a3b8;
}

.streak-dot {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: #e2e8f0;
}

.streak-day.active .streak-dot {
  background: #22c55e;
}

.streak-day.active {
  color: #166534;
  font-weight: 600;
}

/* 30-day streak calendar */
.streak-calendar {
  margin-bottom: 1rem;
}

.streak-calendar-label {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.streak-calendar-grid {
  display: grid;
  grid-template-columns: repeat(15, 1fr);
  gap: 3px;
}

.streak-cal-day {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  color: #94a3b8;
}

.streak-cal-day.active {
  background: #22c55e;
  color: #fff;
  font-weight: 600;
}

.streak-cal-day.today {
  border: 2px solid #2563eb;
}

.streak-cal-num {
  line-height: 1;
}

/* Deadline Widget */
.deadline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.deadline-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.deadline-item:hover {
  border-color: #2563eb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.08);
}

.deadline-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.deadline-icon {
  font-size: 1.2rem;
}

.deadline-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
}

.deadline-course {
  font-size: 0.75rem;
  color: #64748b;
}

.deadline-item-right {
  text-align: right;
}

.deadline-date {
  font-size: 0.82rem;
  font-weight: 500;
  color: #334155;
}

.deadline-countdown {
  font-size: 0.72rem;
  color: #64748b;
}

.deadline-urgent .deadline-countdown {
  color: #dc2626;
  font-weight: 600;
}

.deadline-urgent {
  border-left: 3px solid #dc2626;
  background: #fef2f2;
}

.deadline-soon .deadline-countdown {
  color: #d97706;
  font-weight: 600;
}

.deadline-soon {
  border-left: 3px solid #f59e0b;
}

.deadline-later {
  border-left: 3px solid #16a34a;
}

/* ── Dark Mode Toggle Switch ──────────────────────────────── */

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: 0.3s;
}

.toggle-slider:before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: #2563eb;
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(20px);
}

/* ── Dark Mode ────────────────────────────────────────────── */

body.dark-mode {
  background: #0f172a;
  color: #e2e8f0;
}

body.dark-mode .lesson-meta-bar,
body.dark-mode .pane-card,
body.dark-mode .preview-panel {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .lesson-meta-section label,
body.dark-mode .pane-header {
  color: #cbd5e1;
}

body.dark-mode .lesson-meta-section select {
  background: #0f172a;
  color: #e2e8f0;
  border-color: #334155;
}

body.dark-mode .lesson-title-input {
  color: #f1f5f9;
}

body.dark-mode .lesson-title-input:focus {
  border-bottom-color: #60a5fa;
}

body.dark-mode .editor-toolbar {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .editor-pane textarea {
  background: #0f172a;
  color: #e2e8f0;
}

body.dark-mode .preview-pane .pane-header {
  background: #1a3a52;
  color: #93c5fd;
}

body.dark-mode .pane-card .pane-header {
  border-bottom-color: #334155;
}

body.dark-mode .upload-status {
  color: #cbd5e1;
}

body.dark-mode .editor-notification.success {
  background: #064e3b;
  color: #d1fae5;
  border-color: #10b981;
}

body.dark-mode .editor-notification.error {
  background: #7f1d1d;
  color: #fee2e2;
  border-color: #dc2626;
}

body.dark-mode .profile-card,
body.dark-mode .profile-section {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .profile-info h2,
body.dark-mode .profile-stat-value,
body.dark-mode .badge-title,
body.dark-mode .streak-number {
  color: #f1f5f9;
}

body.dark-mode .profile-email,
body.dark-mode .profile-stat-label,
body.dark-mode .badge-desc,
body.dark-mode .streak-longest,
body.dark-mode .profile-activity-score {
  color: #94a3b8;
}

body.dark-mode .profile-activity-item {
  background: #334155;
}

body.dark-mode .profile-section h3 {
  color: #f1f5f9;
}

body.dark-mode .profile-setting-item span,
body.dark-mode .settings-container h2 {
  color: #f1f5f9;
}

body.dark-mode .setting-hint,
body.dark-mode .settings-section-desc {
  color: #94a3b8;
}

body.dark-mode .notification-email-item {
  border-bottom-color: #334155;
}

body.dark-mode .settings-text-input {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .settings-text-input:focus {
  background: #0f172a;
  border-color: #6366f1;
}

body.dark-mode .btn-add-email {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .btn-add-email:hover:not(:disabled) {
  background: #334155;
  border-color: #6366f1;
}

body.dark-mode .notification-email-chip {
  background: #052e1c;
  border-color: #166534;
  color: #86efac;
}

body.dark-mode .notification-email-chip button {
  color: #86efac;
}

body.dark-mode .notification-email-chip button:hover {
  background: #166534;
}

body.dark-mode .badge-item.earned {
  background: #1a3a2a;
  border-color: #166534;
}

body.dark-mode .badge-item.locked {
  background: #1e293b;
}

body.dark-mode .streak-dot {
  background: #334155;
}

body.dark-mode .student-footer {
  background: #020617;
}

body.dark-mode .form-input {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

/* ── Dark Mode — Global Student Pages ─────────────────────── */

body.dark-mode .courses-sidebar {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .courses-main {
  background: #0f172a;
}

body.dark-mode .courses-welcome h2 {
  color: #f1f5f9;
}

body.dark-mode .courses-welcome p {
  color: #94a3b8;
}

body.dark-mode .student-course-card {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .student-course-card:hover {
  border-color: #3b82f6;
}

body.dark-mode .student-course-card-title {
  color: #f1f5f9;
}

body.dark-mode .student-course-card-meta {
  color: #94a3b8;
}

body.dark-mode .tree-course-name,
body.dark-mode .tree-lesson-link {
  color: #cbd5e1;
}

body.dark-mode .tree-lesson-link:hover {
  color: #fff;
}

body.dark-mode .tree-link-active {
  color: #60a5fa;
}

body.dark-mode .tree-active {
  background: #1e3a5f;
}

body.dark-mode .tree-active::before {
  background: #60a5fa;
}

body.dark-mode .tree-item-read.tree-active,
body.dark-mode .tree-item-quiz.tree-active {
  background: #1e3a5f;
}
body.dark-mode .tree-item-read.tree-active::before,
body.dark-mode .tree-item-quiz.tree-active::before {
  background: #60a5fa;
}

body.dark-mode .tree-item-lab.tree-active {
  background: #1a3a2a;
}
body.dark-mode .tree-item-lab.tree-active::before {
  background: #86efac;
}

body.dark-mode .tree-item-homework.tree-active {
  background: #3b2f1a;
}
body.dark-mode .tree-item-homework.tree-active::before {
  background: #fcd34d;
}

body.dark-mode .tree-active {
  animation-name: tree-active-glow-dark;
}

@keyframes tree-active-glow-dark {
  0% {
    box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.35);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(96, 165, 250, 0);
  }
}

body.dark-mode .lesson-content {
  background: #1e293b;
  color: #e2e8f0;
}

body.dark-mode .lesson-content h1,
body.dark-mode .lesson-content h2,
body.dark-mode .lesson-content h3 {
  color: #f1f5f9;
}

body.dark-mode .lesson-content code {
  background: #334155;
  color: #e2e8f0;
}

body.dark-mode .lesson-content pre {
  background: #0f172a;
}

body.dark-mode .lesson-content table th {
  background: #334155;
  border-color: #475569;
}

body.dark-mode .lesson-content table td {
  border-color: #475569;
}

body.dark-mode .lesson-content tr:nth-child(even) {
  background: #1e293b;
}

body.dark-mode .lesson-content blockquote {
  border-left-color: #475569;
  color: #94a3b8;
}

body.dark-mode .quiz-question-area {
  background: #1e293b;
  color: #e2e8f0;
}

body.dark-mode .quiz-mc-option,
body.dark-mode .quiz-tf-option {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .progress-panel {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .progress-panel-header {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .progress-panel-header h3 {
  color: #f1f5f9;
}

body.dark-mode .progress-panel-content {
  background: #0f172a;
}

body.dark-mode .progress-panel-course {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .progress-panel-course-header span {
  color: #f1f5f9;
}

body.dark-mode .lesson-nav button {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

/* ── Dark Mode — Additional Fixes ─────────────────────────── */

body.dark-mode .sidebar-title {
  color: #f1f5f9;
}

body.dark-mode .sidebar-account-section {
  border-top-color: #334155;
}

body.dark-mode .sidebar-account-link {
  color: #cbd5e1;
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.08), rgba(124, 58, 237, 0.10));
  border-color: rgba(167, 139, 250, 0.18);
}

body.dark-mode .sidebar-account-link:hover {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.16), rgba(124, 58, 237, 0.20));
  border-color: rgba(167, 139, 250, 0.35);
}

body.dark-mode .sidebar-signout-link {
  color: #fca5a5;
  background: rgba(220, 38, 38, 0.12);
  border-color: rgba(248, 113, 113, 0.3);
}

body.dark-mode .sidebar-signout-link:hover {
  background: rgba(220, 38, 38, 0.2);
  border-color: rgba(248, 113, 113, 0.5);
}

body.dark-mode .quiz-question-area h3,
body.dark-mode .quiz-question-area p,
body.dark-mode .quiz-question-area label {
  color: #e2e8f0;
}

body.dark-mode .quiz-meta {
  color: #94a3b8;
}

body.dark-mode #quiz-title {
  color: #f1f5f9;
}

body.dark-mode .quiz-question-area input[type="text"],
body.dark-mode .fitb-quiz-input {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .quiz-nav button {
  background: #334155;
  border-color: #475569;
  color: #e2e8f0;
}

body.dark-mode .quiz-nav button:disabled {
  opacity: 0.4;
}

body.dark-mode .quiz-dot {
  background: #334155;
  border-color: #475569;
  color: #94a3b8;
}

body.dark-mode .quiz-dot.active {
  background: #2563eb;
  color: #fff;
}

body.dark-mode .quiz-dot.answered {
  background: #1e40af;
  color: #fff;
}

body.dark-mode .quiz-submit-area .btn-primary {
  background: #2563eb;
}

body.dark-mode .tree-item a {
  color: #cbd5e1;
}

body.dark-mode .tree-item a:hover {
  color: #fff;
}

body.dark-mode .sidebar-header {
  color: #f1f5f9;
}



body.dark-mode .sidebar-search-input {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}

body.dark-mode .sidebar-search-input:focus {
  background: #0f172a;
  border-color: #6366f1;
}

/* ── Dark Mode — Sidebar Hover Fix ────────────────────────── */

body.dark-mode .tree-course-header {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.08), rgba(124, 58, 237, 0.10));
  border-color: rgba(167, 139, 250, 0.18);
}

body.dark-mode .tree-course-header:hover,
body.dark-mode .tree-course-header.expanded {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.16), rgba(124, 58, 237, 0.20));
  border-color: rgba(167, 139, 250, 0.35);
}

body.dark-mode .tree-course-header:hover .tree-course-name,
body.dark-mode .tree-course-header.expanded .tree-course-name {
  color: #f1f5f9;
}

body.dark-mode .tree-lesson-header:hover {
  background: #334155;
}

body.dark-mode .tree-lesson-header.tree-active {
  background: #1e3a5f;
}

body.dark-mode .tree-lesson-header:hover {
  background: #334155 !important;
}

body.dark-mode .tree-lesson-header:hover .tree-lesson-link {
  color: #f1f5f9;
}

/* ── Dark Mode — Progress Panel Text Fix ──────────────────── */

body.dark-mode .progress-total-points {
  color: #f1f5f9;
}

body.dark-mode .progress-lesson-title {
  color: #cbd5e1;
}

body.dark-mode .progress-item {
  color: #e2e8f0;
}

body.dark-mode .progress-item.pending {
  color: #cbd5e1;
}

body.dark-mode .progress-item.done {
  color: #86efac;
}

body.dark-mode .progress-item.failed {
  color: #fca5a5;
}

body.dark-mode .progress-item-pts {
  color: #94a3b8;
}

body.dark-mode .progress-course-summary {
  color: #94a3b8;
  border-color: #475569;
}

body.dark-mode .progress-panel-points {
  color: #60a5fa;
}

body.dark-mode .progress-toggle-arrow {
  color: #94a3b8;
}

body.dark-mode .progress-items {
  border-left-color: #475569;
}

/* ── Dark Mode — Quiz Question Text Fix ───────────────────── */

body.dark-mode .quiz-question-card {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .quiz-question-header {
  border-bottom-color: #334155;
}

body.dark-mode .quiz-question-text,
body.dark-mode .quiz-question-area .question-text,
body.dark-mode .quiz-question-area > p,
body.dark-mode .quiz-question-area div {
  color: #f1f5f9 !important;
}

body.dark-mode .question-number {
  color: #e2e8f0;
}

body.dark-mode .quiz-question-type {
  background: #334155;
  color: #94a3b8;
}

body.dark-mode .question-indicator {
  color: #94a3b8;
}

body.dark-mode .quiz-previous-result p {
  color: #94a3b8;
}

body.dark-mode .quiz-prev-badge.passed {
  background: #1a3a2a;
  border-color: #166534;
}

body.dark-mode .quiz-prev-badge.failed {
  background: #3b1a1a;
  border-color: #991b1b;
}

/* ── Lesson Animations ────────────────────────────────────── */

/* Scroll fade-in */
.lesson-content h2,
.lesson-content h3,
.lesson-content pre,
.lesson-content table,
.lesson-content blockquote,
.lesson-content .callout {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.lesson-content .animate-in {
  opacity: 1;
  transform: translateY(0);
}

/* Callout Boxes */
.callout {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin: 1.25rem 0;
  border-left: 4px solid;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.callout-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
  line-height: 1.4;
}

.callout-content {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.5;
}

.callout-content p {
  margin: 0;
}

.callout-tip {
  background: #f0fdf4;
  border-color: #22c55e;
  color: #166534;
}

.callout-warning {
  background: #fffbeb;
  border-color: #f59e0b;
  color: #92400e;
}

.callout-info {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1e40af;
}

.callout-danger {
  background: #fef2f2;
  border-color: #ef4444;
  color: #991b1b;
}

/* Dark mode callouts */
body.dark-mode .callout-tip {
  background: #052e16;
  color: #86efac;
}

body.dark-mode .callout-warning {
  background: #451a03;
  color: #fcd34d;
}

body.dark-mode .callout-info {
  background: #172554;
  color: #93c5fd;
}

body.dark-mode .callout-danger {
  background: #450a0a;
  color: #fca5a5;
}

/* Expandable Sections (details/summary) */
.lesson-content details {
  margin: 1rem 0;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.lesson-content details summary {
  padding: 0.75rem 1rem;
  background: #f8fafc;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  color: #0f172a;
  user-select: none;
  transition: background 0.2s;
}

.lesson-content details summary:hover {
  background: #f1f5f9;
}

.lesson-content details[open] summary {
  border-bottom: 1px solid #e2e8f0;
}

.lesson-content details > *:not(summary) {
  padding: 0 1rem 0 1.5rem;
}

.lesson-content details > p:last-child {
  padding-bottom: 1rem;
}

.lesson-content details ul,
.lesson-content details ol {
  padding-left: 1.5rem;
}

/* Dark mode expandable */
body.dark-mode .lesson-content details {
  border-color: #475569;
}

body.dark-mode .lesson-content details summary {
  background: #334155;
  color: #f1f5f9;
}

body.dark-mode .lesson-content details summary:hover {
  background: #3b4f6b;
}

body.dark-mode .lesson-content details[open] summary {
  border-bottom-color: #475569;
}

/* ── Lesson Action Badges (Quiz/Lab/HW at bottom of lesson) ── */

.lesson-action-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.lesson-action-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  border: 1px solid #e2e8f0;
  transition: background 0.2s, border-color 0.2s;
}

.lesson-badge-quiz {
  background: #eff6ff;
  color: #1e40af;
  border-color: #bfdbfe;
}

.lesson-badge-quiz:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}

.lesson-badge-lab {
  background: #ecfdf5;
  color: #065f46;
  border-color: #a7f3d0;
}

.lesson-badge-lab:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.lesson-badge-hw {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

.lesson-badge-hw:hover {
  background: #fef3c7;
  border-color: #fcd34d;
}

/* Dark mode */
body.dark-mode .lesson-action-badge {
  border-color: #475569;
}

body.dark-mode .lesson-badge-quiz {
  background: #1e3a5f;
  color: #93c5fd;
}

body.dark-mode .lesson-badge-lab {
  background: #1a3a2a;
  color: #86efac;
}

body.dark-mode .lesson-badge-hw {
  background: #3b2f1a;
  color: #fcd34d;
}

/* ── Locked Lessons ───────────────────────────────────────── */

.tree-lesson.tree-locked {
  opacity: 0.6;
}

.tree-lesson-locked {
  color: #94a3b8;
  font-size: 0.88rem;
  cursor: not-allowed;
}

body.dark-mode .tree-lesson-locked {
  color: #64748b;
}

/* ── Quiz Review Mode ─────────────────────────────────────── */

.result-review-card {
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 8px;
  border-left: 4px solid;
}

.result-review-card.result-correct {
  background: #f0fdf4;
  border-color: #22c55e;
}

.result-review-card.result-incorrect {
  background: #fef2f2;
  border-color: #ef4444;
}

.result-review-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.result-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.result-question-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: #0f172a;
}

.result-review-answers {
  margin-top: 8px;
  padding-left: 28px;
  font-size: 0.85rem;
}

.result-your-answer {
  color: #dc2626;
  margin-bottom: 4px;
}

/* ── Leaderboard (Redesigned) ─────────────────────────────── */

.leaderboard-container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

.lb-empty {
  text-align: center;
  color: #64748b;
  padding: 3rem 1rem;
}

.lb-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.lb-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.lb-subtitle {
  font-size: 0.82rem;
  color: #94a3b8;
  margin: 4px 0 0;
}

.lb-earn-btn {
  font-size: 0.82rem;
  font-weight: 600;
  color: #0f172a;
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  transition: border-color 0.2s;
}

.lb-earn-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

/* Podium */
.lb-podium {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1.5rem 0;
}

.lb-podium-item {
  text-align: center;
  padding: 1.25rem 1.5rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  min-width: 130px;
  position: relative;
}

.lb-podium-first {
  border-color: #fcd34d;
  background: #fffbeb;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(252, 211, 77, 0.2);
}

.lb-crown {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
}

.lb-podium-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  margin: 0 auto 8px;
}

.lb-podium-name {
  font-weight: 600;
  font-size: 0.85rem;
  color: #0f172a;
}

.lb-podium-points {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-top: 2px;
}

.lb-podium-label {
  font-size: 0.72rem;
  color: #94a3b8;
}

.lb-podium-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #f1f5f9;
  font-size: 0.72rem;
  font-weight: 700;
  color: #475569;
  margin-top: 8px;
}

/* Table */
.lb-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
}

.lb-row {
  transition: background 0.15s;
}

.lb-row:hover {
  background: #f8fafc;
}

.lb-row-me {
  background: #eff6ff;
}

.lb-row td {
  padding: 14px 12px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.88rem;
}

.lb-cell-rank {
  width: 40px;
  font-weight: 700;
  color: #475569;
}

.lb-cell-student {
  min-width: 200px;
}

.lb-student-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.lb-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.lb-student-name {
  font-weight: 600;
  color: #0f172a;
}

.lb-you {
  font-size: 0.7rem;
  font-weight: 600;
  color: #2563eb;
  background: #eff6ff;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

.lb-student-lessons {
  font-size: 0.75rem;
  color: #94a3b8;
}

.lb-cell-points {
  min-width: 140px;
}

.lb-points-bar {
  height: 5px;
  background: #f1f5f9;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}

.lb-points-fill {
  height: 100%;
  border-radius: 3px;
}

.lb-points-num {
  font-size: 0.82rem;
  font-weight: 600;
  color: #0f172a;
}

.lb-cell-num {
  text-align: center;
  font-weight: 500;
  color: #334155;
}

/* Footer banner */
.lb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  background: #eff6ff;
  border-radius: 12px;
  border: 1px solid #bfdbfe;
}

.lb-footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lb-footer-rank {
  font-size: 0.88rem;
  font-weight: 600;
  color: #0f172a;
}

.lb-footer-hint {
  font-size: 0.78rem;
  color: #64748b;
}

.lb-footer-btn {
  font-size: 0.82rem;
  font-weight: 600;
  color: #0f172a;
  padding: 8px 16px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  background: #fff;
}

.lb-footer-btn:hover {
  border-color: #2563eb;
  color: #2563eb;
}

@media (max-width: 768px) {
  .lb-podium {
    flex-direction: column;
    align-items: center;
  }

  .lb-podium-first {
    transform: none;
  }

  .lb-header {
    flex-direction: column;
    gap: 10px;
  }

  .lb-cell-points {
    display: none;
  }

  .lb-footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

/* ── Certificates ─────────────────────────────────────────── */

.certificates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.certificate-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  font-size: 0.9rem;
}

.certificate-item.certificate-locked {
  background: #f8fafc;
  border-color: #e2e8f0;
}

.certificate-progress {
  font-size: 0.8rem;
  color: #64748b;
}

body.dark-mode .certificate-item {
  background: #1a3a2a;
  border-color: #166534;
}

body.dark-mode .certificate-item.certificate-locked {
  background: #1e293b;
  border-color: #334155;
}

/* ── Start Lab Terminal Button ─────────────────────────────── */

.lab-terminal-section {
  margin: 1.5rem 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-start-lab {
  padding: 10px 20px;
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-start-lab:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.3);
}

.btn-start-lab:disabled {
  opacity: 0.7;
  cursor: wait;
}

.lab-terminal-status {
  font-size: 0.85rem;
}

.lab-terminal-status.success {
  color: #16a34a;
}

.lab-terminal-status.error {
  color: #dc2626;
}

/* ===== Lab Editor - Grading Policy ===== */
.required-indicator {
  color: #dc2626;
  font-weight: 700;
}

.field-error {
  display: block;
  color: #dc2626;
  font-size: 0.82rem;
  margin-top: 4px;
}

.grading-method-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
}

.grading-badge {
  display: inline-block;
  background: #dcfce7;
  color: #166534;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 6px;
}

.grading-hint {
  font-size: 0.82rem;
  color: #64748b;
}

/* ── Homework Attempt History Accordion ────────────────────── */
.homework-submission-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  align-items: stretch;
}

.submission-detail-panel {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.attempt-history-panel {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

.attempt-accordion {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.attempt-accordion-item {
  border-bottom: 1px solid #e2e8f0;
}

.attempt-accordion-item:last-child {
  border-bottom: none;
}

.attempt-accordion-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: #fff;
  cursor: pointer;
  text-align: left;
  font-size: 0.88rem;
  color: #334155;
  transition: background 0.15s;
}

.attempt-accordion-header:hover {
  background: #f8fafc;
}

.attempt-accordion-header.active {
  background: #f0f4ff;
  border-left: 3px solid #3b82f6;
}

.attempt-accordion-chevron {
  flex-shrink: 0;
  font-size: 0.75rem;
  color: #94a3b8;
  transition: transform 0.2s;
}

.attempt-accordion-header.active .attempt-accordion-chevron {
  transform: rotate(90deg);
}

.attempt-accordion-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.attempt-accordion-title {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.85rem;
}

.attempt-accordion-timestamp {
  font-size: 0.75rem;
  color: #64748b;
}

.attempt-accordion-score {
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}

.attempt-accordion-score.score-excellent {
  color: #059669;
}

.attempt-accordion-score.score-good {
  color: #2563eb;
}

.attempt-accordion-score.score-fair {
  color: #d97706;
}

.attempt-accordion-score.score-poor {
  color: #dc2626;
}

.attempt-accordion-body {
  display: none;
  padding: 16px;
  border-top: 1px solid #e2e8f0;
  background: #fafbfc;
}

.attempt-accordion-item.expanded .attempt-accordion-body {
  display: block;
}

.attempt-feedback-section {
  margin-bottom: 1rem;
}

.attempt-feedback-section h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  margin: 0 0 8px;
}

.attempt-feedback-content {
  font-size: 0.82rem;
  color: #334155;
  line-height: 1.6;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
}

.attempt-submission-section h4 {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  margin: 0 0 8px;
}

.attempt-submission-text {
  font-size: 0.82rem;
  color: #64748b;
  line-height: 1.6;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Lab Grading Policy - Due Date & Status ───────────────── */

.lab-due-date {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.88rem;
  margin: 1rem 0;
}

.lab-due-date-upcoming {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.lab-due-date-past {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #991b1b;
}

.lab-due-date-icon {
  font-size: 1rem;
}

body.dark-mode .lab-due-date-upcoming {
  background: #1e293b;
  border-color: #334155;
  color: #93c5fd;
}

body.dark-mode .lab-due-date-past {
  background: #1e293b;
  border-color: #7f1d1d;
  color: #fca5a5;
}

/* Lab Pass/Fail Status Badge */
.lab-status-section {
  margin: 1rem 0;
}

.lab-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
}

.lab-status-passed {
  background: #f0fdf4;
  border: 2px solid #86efac;
  color: #166534;
}

.lab-status-not-passed {
  background: #fefce8;
  border: 2px solid #fde047;
  color: #854d0e;
}

.lab-status-icon {
  font-size: 1.2rem;
  font-weight: 700;
}

.lab-status-text {
  font-size: 1rem;
}

.lab-status-hint {
  margin-top: 8px;
  font-size: 0.82rem;
  color: #64748b;
}

body.dark-mode .lab-status-passed {
  background: #052e16;
  border-color: #166534;
  color: #86efac;
}

body.dark-mode .lab-status-not-passed {
  background: #422006;
  border-color: #854d0e;
  color: #fde047;
}

body.dark-mode .lab-status-hint {
  color: #94a3b8;
}

/* Lab Submission History Timeline */
.lab-history-timeline {
  margin: 0.5rem 0;
}

.lab-timeline {
  position: relative;
  padding-left: 24px;
}

.lab-timeline::before {
  content: '';
  position: absolute;
  left: 9px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #e2e8f0;
  border-radius: 1px;
}

.lab-timeline-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
}

.lab-timeline-item:first-child {
  padding-top: 0;
}

.lab-timeline-item:last-child {
  padding-bottom: 0;
}

.lab-timeline-marker {
  position: absolute;
  left: -24px;
  top: 12px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.lab-timeline-item:first-child .lab-timeline-marker {
  top: 2px;
}

.timeline-passed .lab-timeline-marker {
  background: #16a34a;
}

.timeline-failed .lab-timeline-marker {
  background: #dc2626;
}

.lab-timeline-content {
  flex: 1;
  min-width: 0;
}

.lab-timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.lab-timeline-attempt {
  font-weight: 600;
  font-size: 0.88rem;
  color: #0f172a;
}

.lab-timeline-result {
  font-size: 0.78rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.timeline-passed .lab-timeline-result {
  background: #dcfce7;
  color: #166534;
}

.timeline-failed .lab-timeline-result {
  background: #fef2f2;
  color: #991b1b;
}

.lab-timeline-time {
  font-size: 0.78rem;
  color: #64748b;
  margin-top: 2px;
}

body.dark-mode .lab-timeline::before {
  background: #334155;
}

body.dark-mode .lab-timeline-attempt {
  color: #f1f5f9;
}

body.dark-mode .lab-timeline-time {
  color: #94a3b8;
}

body.dark-mode .timeline-passed .lab-timeline-result {
  background: #052e16;
  color: #86efac;
}

body.dark-mode .timeline-failed .lab-timeline-result {
  background: #450a0a;
  color: #fca5a5;
}

/* ── Student Toast Notifications ──────────────────────────── */
.student-toast-container {
  position: fixed;
  top: 60px;
  right: 16px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.student-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  font-size: 0.88rem;
  animation: toast-slide-in 0.3s ease;
}

.student-toast-success { border-left: 4px solid #16a34a; }
.student-toast-error { border-left: 4px solid #dc2626; }
.student-toast-info { border-left: 4px solid #2563eb; }
.student-toast-warning { border-left: 4px solid #f59e0b; }

.student-toast-icon { font-size: 1rem; flex-shrink: 0; }
.student-toast-msg { flex: 1; color: #334155; }
.student-toast-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #94a3b8;
  cursor: pointer;
  padding: 0 4px;
}

.student-toast-hiding {
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s, transform 0.3s;
}

@keyframes toast-slide-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

body.dark-mode .student-toast {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .student-toast-msg {
  color: #e2e8f0;
}

/* ── Skeleton Loading States ──────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 6px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-text-short {
  height: 14px;
  margin-bottom: 8px;
  width: 50%;
}

.skeleton-card {
  height: 120px;
  border-radius: 12px;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

body.dark-mode .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #334155 50%, #1e293b 75%);
  background-size: 200% 100%;
}

/* ── Draft Autosave Indicator ─────────────────────────────── */
.draft-indicator {
  display: inline-block;
  font-size: 0.75rem;
  color: #16a34a;
  margin-left: 8px;
  opacity: 1;
  transition: opacity 0.5s;
}

/* ── Button Loading Spinner ───────────────────────────────── */
.btn-loading {
  position: relative;
  pointer-events: none;
  opacity: 0.7;
}

.btn-loading::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: btn-spin 0.6s linear infinite;
}

.btn-loading.btn-loading-dark::after {
  border-color: rgba(0,0,0,0.15);
  border-top-color: #334155;
}

@keyframes btn-spin {
  to { transform: rotate(360deg); }
}

/* Quiz Timer */
.quiz-timer {
  font-size: 0.82rem;
  font-weight: 600;
  color: #64748b;
  padding: 4px 10px;
  background: #f1f5f9;
  border-radius: 6px;
  white-space: nowrap;
}

body.dark-mode .quiz-timer {
  background: #334155;
  color: #94a3b8;
}

/* ── Animated Progress Bars (fill on appear) ──────────────── */
.dashboard-progress-fill,
.lb-points-fill,
.hw-history-mini-fill,
.attempt-mini-bar-fill {
  animation: progress-fill-in 0.8s ease-out forwards;
}

@keyframes progress-fill-in {
  from { width: 0; }
}

/* ── Grading Split Panel (Master-Detail) ──────────────────── */
.grading-split-panel {
  display: flex;
  gap: 1.5rem;
  min-height: 500px;
}

.grading-left-panel {
  width: 320px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grading-right-panel {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  max-height: 70vh;
}

.grading-search-bar {
  margin-bottom: 8px;
}

.grading-student-list-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
  max-height: 60vh;
}

.grading-student-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.15s;
}

.grading-student-card:hover {
  border-color: #cbd5e1;
  background: #f8fafc;
}

.grading-student-card.selected {
  border-color: #2563eb;
  background: #eff6ff;
}

.grading-sc-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.grading-sc-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
  flex-shrink: 0;
}

.grading-sc-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: #0f172a;
}

.grading-sc-email {
  font-size: 0.75rem;
  color: #64748b;
}

.grading-sc-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grading-sc-status {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.grading-sc-status.active {
  color: #166534;
  background: #dcfce7;
}

.grading-sc-status.expired {
  color: #991b1b;
  background: #fee2e2;
}

.grading-sc-arrow {
  font-size: 1.2rem;
  color: #94a3b8;
}

/* Right panel checklist */
.grading-checklist-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding-bottom: 10px;
  border-bottom: 1px solid #e2e8f0;
}

.grading-checklist-header h3 {
  margin: 0;
  font-size: 1rem;
  color: #0f172a;
}

.grading-checklist-pct {
  font-size: 1.1rem;
  font-weight: 700;
  color: #16a34a;
  border: 2px solid #16a34a;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grading-checklist-empty {
  text-align: center;
  padding: 3rem;
  color: #94a3b8;
  font-size: 0.9rem;
}

.grading-lesson-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 10px;
}

.grading-lesson-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #f1f5f9;
}

.grading-lesson-pct {
  font-size: 0.8rem;
  color: #64748b;
}

.grading-item-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
}

.grading-item-name {
  font-size: 0.85rem;
  color: #334155;
}

.grading-item-status {
  font-size: 0.78rem;
}

.grading-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}

.grading-badge-complete {
  background: #dcfce7;
  color: #166534;
}

.grading-badge-graded {
  background: #dcfce7;
  color: #166534;
}

.grading-badge-pending {
  background: #fef3c7;
  color: #92400e;
}

.grading-badge-notstarted {
  background: #f1f5f9;
  color: #64748b;
}

.grading-badge-notsubmitted {
  background: #f1f5f9;
  color: #64748b;
}

@media (max-width: 768px) {
  .grading-split-panel {
    flex-direction: column;
  }
  .grading-left-panel {
    width: 100%;
    min-width: unset;
  }
}

/* ── Skip to content (accessibility) ──────────────────────── */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-primary-dark);
  color: #fff;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 10000;
  text-decoration: none;
  border-radius: 0 0 6px 0;
  transition: top 0.1s;
}

.skip-link:focus {
  top: 0;
}

/* ── Inline field errors (form validation) ─────────────────── */
.field-error {
  display: none;
  font-size: 0.78rem;
  color: var(--color-error);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.field-error[hidden] {
  display: none !important;
}

.form-input.input-error,
input.input-error,
textarea.input-error,
select.input-error {
  border-color: var(--color-error) !important;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1) !important;
}

.form-input.input-valid,
input.input-valid,
textarea.input-valid,
select.input-valid {
  border-color: var(--color-success-dark) !important;
}

/* ── Quiz dots — mobile scroll instead of wrap ─────────────── */
@media (max-width: 600px) {
  .quiz-question-dots {
    flex-wrap: nowrap;
    overflow-x: auto;
    justify-content: flex-start;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .quiz-dot {
    flex-shrink: 0;
  }
}

/* ── Quiz progress bar (question counter) ──────────────────── */
.quiz-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.quiz-progress-counter {
  font-size: 0.88rem;
  color: var(--color-muted);
  font-weight: 500;
}

.quiz-progress-bar-wrap {
  flex: 1;
  margin: 0 1rem;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Keyboard hint tooltip ─────────────────────────────────── */
.quiz-kbd-hint {
  font-size: 0.75rem;
  color: var(--color-muted-2);
  text-align: center;
  margin-top: 0.5rem;
}

.quiz-kbd-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 0.7rem;
  font-family: inherit;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  margin: 0 2px;
}

/* ── Quiz intro / lobby screen ──────────────────────────────── */
.quiz-intro-card {
  max-width: 480px;
  margin: 2.5rem auto;
  background: var(--color-card-bg, #fff);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 2rem 2.25rem;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

.quiz-intro-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
}

.quiz-intro-heading {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0 0 1.25rem;
  color: var(--color-text);
}

.quiz-intro-meta {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.25rem;
  text-align: left;
}

.quiz-intro-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
}

.quiz-intro-row:not(:last-child) {
  border-bottom: 1px solid var(--color-border);
}

.quiz-intro-label {
  color: var(--color-muted-2);
}

.quiz-intro-value {
  font-weight: 600;
  color: var(--color-text);
}

.quiz-intro-hint {
  font-size: 0.82rem;
  color: var(--color-muted-2);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.quiz-intro-start-btn {
  width: 100%;
  padding: 0.8rem;
  font-size: 1rem;
  border-radius: 8px;
}

body.dark-mode .quiz-intro-card {
  background: var(--color-card-bg-dark, #1e2330);
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

/* ── Admin search bar (students, classes) ──────────────────── */
.admin-search-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-search-input {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 9px 12px 9px 36px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 16 16' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='4'/%3E%3Cpath d='M11 11l3 3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 11px center;
  color: var(--color-dark);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.admin-search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}

.admin-search-input::placeholder {
  color: var(--color-muted-2);
}

.admin-search-count {
  font-size: 12px;
  color: var(--color-muted);
  white-space: nowrap;
}

/* ── CSV Export button ─────────────────────────────────────── */
.btn-export {
  padding: 8px 14px;
  border: 1px solid var(--color-border);
  background: #fff;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--color-dark-4);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn-export:hover {
  background: var(--color-bg);
  border-color: var(--color-muted-2);
  color: var(--color-dark);
}

/* ── Admin overview stats bar ──────────────────────────────── */
.admin-overview-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.admin-overview-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-overview-card-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--color-dark);
  line-height: 1.1;
}

.admin-overview-card-label {
  font-size: 0.78rem;
  color: var(--color-muted);
  font-weight: 500;
}

.admin-overview-card.pending-attention {
  border-left: 3px solid var(--color-warning);
}

.admin-overview-card.pending-attention .admin-overview-card-value {
  color: var(--color-warning-dark);
}

/* ── Bulk selection (students table) ───────────────────────── */
.bulk-actions-bar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--color-primary-bg);
  border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--color-primary-dark);
  font-weight: 500;
}

.bulk-actions-bar.visible {
  display: flex;
}

.bulk-actions-bar .bulk-count {
  flex: 1;
}

.checkbox-col {
  width: 40px;
  padding-left: 16px !important;
}

.row-checkbox,
.header-checkbox {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--color-primary);
}

/* ── aria-live toast region ────────────────────────────────── */
.student-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  /* aria-live region is set on this element in toast.js */
}

/* ── Focus visible ring (modal trap) ──────────────────────── */
.modal:focus {
  outline: none;
}

[data-focus-trap] *:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ── Grading Split Panel (new pending-submissions queue) ────── */
.grading-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.grading-count-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-bg);
  color: var(--color-muted);
  border: 1px solid var(--color-border);
}

.grading-count-badge.has-items {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

/* ── Grading 3-column layout ────────────────────────────────── */
.grading-3col {
  display: flex;
  height: calc(100vh - 160px);
  min-height: 500px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-bg);
}

.grading-col {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.grading-col-students {
  width: 210px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-1, #f8fafc);
}

.grading-col-lessons {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--color-border);
  background: var(--color-surface-1, #f8fafc);
}

.grading-col-detail {
  flex: 1;
  background: #fff;
}

.grading-col-header {
  padding: 11px 14px;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  border-bottom: 1px solid var(--color-border);
  background: #f1f5f9;
  flex-shrink: 0;
}

.grading-col-body {
  flex: 1;
  overflow-y: auto;
}

.grading-col-placeholder {
  padding: 28px 16px;
  text-align: center;
  color: var(--color-muted-2, #94a3b8);
  font-size: 0.82rem;
}

.grading-col-empty {
  text-align: center;
  padding: 36px 16px;
  color: var(--color-muted);
  font-size: 13px;
}

.grading-col-empty p { margin: 5px 0; }

.grading-col-loading {
  text-align: center;
  padding: 20px;
  color: var(--color-muted);
  font-size: 13px;
}

/* Student column items */
.grading-student-item {
  position: relative;
  display: block;
  width: 100%;
  padding: 11px 36px 11px 14px;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  font-family: inherit;
  transition: background var(--transition-fast);
}

.grading-student-item:hover { background: #f0f4f8; }

.grading-student-item.active {
  background: #eff6ff;
  box-shadow: inset 3px 0 0 #3b82f6;
}

.grading-student-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-dark);
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grading-student-email {
  font-size: 0.72rem;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.grading-student-badge {
  position: absolute;
  top: 11px;
  right: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* Lesson column items */
.grading-lesson-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
}

.grading-lesson-item.active { background: #f0f7ff; }

.grading-lesson-course {
  font-size: 0.67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
  margin-bottom: 2px;
}

.grading-lesson-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--color-dark);
  margin-bottom: 8px;
  line-height: 1.35;
}

.grading-lesson-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.grading-lesson-badge {
  padding: 4px 9px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  font-family: inherit;
}

.grading-lesson-badge-lab {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.grading-lesson-badge-hw {
  background: #dcfce7;
  color: #15803d;
  border-color: #bbf7d0;
}

.grading-lesson-badge:hover { opacity: 0.8; }

.grading-lesson-badge.active {
  background: #3b82f6 !important;
  color: #fff !important;
  border-color: #3b82f6 !important;
}

.grading-lesson-badge-hw.active {
  background: #16a34a !important;
  border-color: #16a34a !important;
}

.grading-lesson-badge-quiz {
  background: #fdf4ff;
  color: #7e22ce;
  border-color: #e9d5ff;
}

.grading-lesson-badge-quiz.active {
  background: #7e22ce !important;
  border-color: #7e22ce !important;
}

.gl-badge-score {
  font-weight: 700;
  margin-left: 2px;
}

/* Quiz result (read-only detail panel) */
.grading-quiz-result {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 0;
  gap: 12px;
}

.grading-quiz-ring-wrap {
  position: relative;
  width: 100px;
  height: 100px;
}

.grading-quiz-ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.grading-quiz-score {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--color-dark);
  line-height: 1;
}

.grading-quiz-sublabel {
  font-size: 0.6rem;
  color: var(--color-muted);
  margin-top: 2px;
}

.grading-quiz-badge {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
}

.grading-quiz-badge.passed { background: #dcfce7; color: #15803d; }
.grading-quiz-badge.failed { background: #fee2e2; color: #dc2626; }

.grading-quiz-points {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.grading-quiz-note {
  font-size: 0.78rem;
  color: var(--color-muted-2, #94a3b8);
  font-style: italic;
  margin-top: 4px;
}

/* Shared type badges (used in detail panel header) */
.grading-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.grading-type-lab  { background: #dbeafe; color: #1d4ed8; }
.grading-type-hw   { background: #dcfce7; color: #15803d; }
.grading-type-quiz { background: #fdf4ff; color: #7e22ce; }

.grading-ai-tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  background: #ede9fe;
  color: #6d28d9;
}

/* Detail column */
.grading-detail-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--color-muted);
  gap: 14px;
  font-size: 14px;
  height: 100%;
}

.grading-detail-empty-icon {
  font-size: 42px;
  opacity: 0.35;
}

.grading-detail-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px 26px;
  height: 100%;
}

/* Detail sections */
.grading-detail-header {
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--color-border);
}

.grading-detail-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.grading-detail-title h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  color: var(--color-dark);
}

.grading-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13px;
  color: var(--color-muted);
}

.grading-section {
  margin-bottom: 20px;
}

.grading-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 8px;
}

.grading-content-box {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--color-dark);
}

.grading-submission-content {
  max-height: 220px;
  overflow-y: auto;
}

.grading-screenshot-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--color-primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  padding: 6px 0;
}

.grading-screenshot-link:hover {
  text-decoration: underline;
}

/* Grade form */
.grading-form {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 4px;
}

.grading-form-row {
  display: flex;
  gap: 20px;
  margin-bottom: 16px;
}

.grading-score-col {
  flex-shrink: 0;
}

.grading-feedback-col {
  flex: 1;
}

.grading-field-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 7px;
}

.grading-score-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.grading-score-input {
  width: 76px;
  padding: 10px 10px;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  color: var(--color-dark);
  background: #fff;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  font-family: inherit;
}

.grading-score-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
  outline: none;
}

.grading-score-input:disabled {
  opacity: 0.5;
  background: var(--color-bg);
}

.grading-score-denom {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-muted);
}

.grading-feedback-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  color: var(--color-dark);
  background: #fff;
  transition: border-color var(--transition-fast);
  box-sizing: border-box;
}

.grading-feedback-input:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.08);
}

.grading-feedback-input:disabled {
  opacity: 0.5;
  background: var(--color-bg);
}

.grading-form-footer {
  display: flex;
  align-items: center;
  gap: 14px;
}

.grading-submit-msg {
  font-size: 14px;
  font-weight: 500;
}

@media (max-width: 900px) {
  .grading-3col {
    flex-direction: column;
    height: auto;
    min-height: unset;
  }
  .grading-col-students,
  .grading-col-lessons {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
    max-height: 220px;
  }
  .grading-form-row {
    flex-direction: column;
  }
}

/* ══════════════════════════════════════════════════════════════
   Brand pattern layer
   Carries the sidebar's cyan→violet look (gradient accents, light
   gradient washes, soft indigo borders) across shared components.
   Kept as one block at the end so it overrides the older blue styles
   and can be reviewed or rolled back in one place.
   ══════════════════════════════════════════════════════════════ */

:root {
  --brand-gradient: linear-gradient(135deg, #06b6d4, #7c3aed);
  --brand-wash: linear-gradient(90deg, #ecfeff, #f5f3ff);
  --brand-wash-strong: linear-gradient(90deg, #cffafe, #ede9fe);
  --brand-border: #e0e7ff;
  --brand-wash-dark: linear-gradient(90deg, rgba(6, 182, 212, 0.08), rgba(124, 58, 237, 0.10));
  --brand-border-dark: rgba(167, 139, 250, 0.18);
}

/* Primary actions: Start Quiz, Submit Homework/Lab, Sign In, Save… */
button[type="submit"],
.btn-primary {
  background: var(--brand-gradient);
}

button[type="submit"]:hover,
.btn-primary:hover {
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.28);
}

/* Inputs: violet focus ring instead of blue */
input:focus,
select:focus,
textarea:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

/* Switches (Dark mode, notification preferences) */
.toggle-switch input:checked + .toggle-slider {
  background: var(--brand-gradient);
}

/* Progress bars (dashboard course cards, student cards, admin matrix) */
.dashboard-progress-fill,
.student-course-card-progress .progress-fill,
.matrix-course-bar-fill {
  background: var(--brand-gradient);
}

/* Avatar circles */
.student-header-avatar,
.profile-avatar {
  background: var(--brand-gradient);
}

.student-header-avatar:hover {
  background: linear-gradient(135deg, #0891b2, #6d28d9);
}

/* Card sections (Settings, Profile): spaced apart, each with a light
   brand-wash title band like the sidebar header */
.profile-section {
  border-color: var(--brand-border);
  overflow: hidden;
}

.settings-container .profile-section + .profile-section {
  margin-top: 16px;
}

.profile-section > h3:first-child {
  margin: -1.5rem -1.5rem 1rem;
  padding: 0.85rem 1.5rem;
  background: var(--brand-wash);
  border-bottom: 1px solid var(--brand-border);
}

body.dark-mode .profile-section {
  border-color: var(--brand-border-dark);
}

body.dark-mode .profile-section > h3:first-child {
  background: var(--brand-wash-dark);
  border-bottom-color: var(--brand-border-dark);
}

/* Sign-in / forgot-password / payment-success cards */
body:has(> .auth-container) {
  background: linear-gradient(160deg, #ecfeff 0%, #f5f3ff 55%, #f8fafc 100%);
  min-height: 100vh;
}

.auth-container {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--brand-border);
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.10);
  padding-top: 2.4rem;
}

.auth-container::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--brand-gradient);
}

.auth-container button[type="submit"] {
  width: 100%;
  justify-content: center;
  padding: 11px 20px;
  font-size: 14px;
}

/* My Progress panel: same gradient +/− toggles and brand-wash course
   cards as the sidebar. The ▼ text progress-panel.js writes is hidden;
   the icon is drawn here and follows the .collapsed class on the card. */
.progress-panel-course {
  border-color: var(--brand-border);
}

.progress-panel-course-header {
  margin: -1rem -1rem 4px;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  background: var(--brand-wash);
}

.progress-panel-course:not(.collapsed) .progress-panel-course-header {
  background: var(--brand-wash-strong);
  border-bottom: 1px solid var(--brand-border);
  border-radius: 8px 8px 0 0;
  margin-bottom: 0.75rem;
}

.progress-panel-course.collapsed .progress-panel-course-header {
  margin-bottom: -1rem;
}

.progress-panel-course-header > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.progress-toggle-arrow,
.progress-panel-course.collapsed .progress-toggle-arrow {
  position: relative;
  display: inline-flex;
  width: 20px;
  height: 20px;
  margin-right: 0;
  border-radius: 50%;
  font-size: 0;
  flex-shrink: 0;
  transform: none;
  background: #e2e8f0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.progress-panel-course.collapsed .progress-toggle-arrow {
  background: var(--brand-gradient);
  box-shadow: 0 2px 6px rgba(124, 58, 237, 0.3);
}

.progress-toggle-arrow::before,
.progress-toggle-arrow::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  border-radius: 2px;
  background: #7c3aed;
  transform: translate(-50%, -50%);
  transition: transform 0.2s ease, background 0.2s ease;
}

.progress-toggle-arrow::before { width: 9px; height: 2px; }
.progress-toggle-arrow::after  { width: 2px; height: 9px; transform: translate(-50%, -50%) scaleY(0); }

.progress-panel-course.collapsed .progress-toggle-arrow::before,
.progress-panel-course.collapsed .progress-toggle-arrow::after {
  background: #fff;
}

.progress-panel-course.collapsed .progress-toggle-arrow::after {
  transform: translate(-50%, -50%);
}

body.dark-mode .progress-panel-course {
  border-color: var(--brand-border-dark);
}

body.dark-mode .progress-panel-course-header {
  background: var(--brand-wash-dark);
}

body.dark-mode .progress-panel-course:not(.collapsed) .progress-panel-course-header {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.16), rgba(124, 58, 237, 0.20));
  border-bottom-color: var(--brand-border-dark);
}

body.dark-mode .progress-toggle-arrow {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px #a78bfa;
}

body.dark-mode .progress-toggle-arrow::before { background: #c4b5fd; }

@media (prefers-reduced-motion: reduce) {
  .progress-toggle-arrow, .progress-toggle-arrow::before, .progress-toggle-arrow::after { transition: none; }
}

/* Sidebar profile row (avatar + name → profile, gear → settings).
   Replaces the old Settings button; on pages with this sidebar the
   header avatar is hidden so the profile isn't shown twice. */
@media (min-width: 769px) {
  body:has(.courses-sidebar) #header-avatar {
    display: none;
  }
}

.sidebar-profile-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sidebar-profile-link {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 10px;
  text-decoration: none;
  color: #0f172a;
  transition: background 0.15s;
}

.sidebar-profile-link:hover {
  background: var(--brand-wash);
}

.sidebar-profile-avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-profile-name {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-settings-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #475569;
  transition: background 0.15s, color 0.15s, transform 0.3s;
}

.sidebar-settings-btn:hover {
  background: var(--brand-wash-strong);
  color: #7c3aed;
  transform: rotate(45deg);
}

.sidebar-profile-link:focus-visible,
.sidebar-settings-btn:focus-visible {
  outline: 2px solid #8b5cf6;
  outline-offset: 2px;
}

body.dark-mode .sidebar-profile-link { color: #f1f5f9; }
body.dark-mode .sidebar-profile-link:hover { background: var(--brand-wash-dark); }
body.dark-mode .sidebar-settings-btn { color: #cbd5e1; }
body.dark-mode .sidebar-settings-btn:hover { background: var(--brand-wash-dark); color: #c4b5fd; }

.courses-sidebar.collapsed .sidebar-profile-row {
  flex-direction: column;
  gap: 4px;
}

.courses-sidebar.collapsed .sidebar-profile-link {
  padding: 4px;
  justify-content: center;
}

.courses-sidebar.collapsed .sidebar-profile-name {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-settings-btn, .sidebar-settings-btn:hover { transition: none; transform: none; }
}

/* Profile page: the header avatar would just link to the page you're on */
body:has(#profile-avatar-wrap) #header-avatar {
  display: none;
}

/* Top-bar Leaderboard / My Progress line icons */
.header-link-icon {
  flex-shrink: 0;
  display: block;
}

.header-link-icon--gold { color: #fbbf24; }
.header-link-icon--cyan { color: #22d3ee; }

.student-header-link[aria-current="page"] {
  background: rgba(124, 58, 237, 0.22);
  border-color: rgba(167, 139, 250, 0.6);
}

/* Profile, Leaderboard and My Progress now sit inside the sidebar layout:
   .courses-main already pads the content area, so drop their own outer
   margin/padding to avoid doubled spacing. */
.courses-main > .profile-container,
.courses-main > .leaderboard-container {
  margin-top: 0;
  margin-bottom: 0;
}

.courses-main > .student-content {
  padding: 0;
}

.sidebar-profile-link[aria-current="page"] {
  background: var(--brand-wash-strong);
  box-shadow: inset 0 0 0 1px var(--brand-border);
}

body.dark-mode .sidebar-profile-link[aria-current="page"] {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.16), rgba(124, 58, 237, 0.20));
  box-shadow: inset 0 0 0 1px var(--brand-border-dark);
}

/* ══════════════════════════════════════════════════════════════
   Leaderboard (lb2): single header, "your standing" card, stepped
   podium with medal rings, and card-row ranking list.
   ══════════════════════════════════════════════════════════════ */

.courses-main > .leaderboard-container {
  max-width: 880px;
}

.lb2-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.lb2-header-icon {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d97706;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  box-shadow: 0 4px 12px rgba(217, 119, 6, 0.18);
}

.lb2-title {
  margin: 0;
  font-size: 1.6rem;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.01em;
}

.lb2-subtitle {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

/* Your standing */
.lb2-me {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  margin-bottom: 28px;
  border-radius: 16px;
  border: 1px solid var(--brand-border);
  background: var(--brand-wash);
}

.lb2-me-avatar {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  box-shadow: 0 0 0 3px #fff, 0 0 0 5px #a78bfa;
}

.lb2-me-text { flex: 1; min-width: 0; }

.lb2-me-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7c3aed;
}

.lb2-me-rank {
  font-size: 1.5rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.lb2-me-rank span {
  font-size: 0.9rem;
  font-weight: 500;
  color: #64748b;
}

.lb2-me-hint {
  font-size: 0.85rem;
  color: #475569;
}

.lb2-me-points {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0 8px;
}

.lb2-me-points strong {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.1;
  background: var(--brand-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  font-variant-numeric: tabular-nums;
}

.lb2-me-points span { font-size: 0.75rem; color: #64748b; }

.lb2-me-btn {
  flex-shrink: 0;
  padding: 10px 18px;
  border-radius: 10px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: box-shadow 0.2s, transform 0.2s;
}

.lb2-me-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(124, 58, 237, 0.28);
}

/* Podium */
.lb2-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 180px));
  justify-content: center;
  align-items: end;
  gap: 16px;
  margin-bottom: 32px;
}

.lb2-podium-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.lb2-podium-crown {
  height: 24px;
  margin-bottom: 2px;
}

.lb2-podium-ring {
  position: relative;
  padding: 4px;
  border-radius: 50%;
  margin-bottom: 10px;
}

.lb2-gold .lb2-podium-ring   { background: linear-gradient(135deg, #fde68a, #f59e0b); }
.lb2-silver .lb2-podium-ring { background: linear-gradient(135deg, #f1f5f9, #94a3b8); }
.lb2-bronze .lb2-podium-ring { background: linear-gradient(135deg, #fed7aa, #c2410c); }

.lb2-podium-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #fff;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.lb2-gold .lb2-podium-avatar {
  width: 80px;
  height: 80px;
  font-size: 1.4rem;
}

.lb2-medal {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 800;
  color: #fff;
}

.lb2-gold .lb2-medal   { background: #f59e0b; }
.lb2-silver .lb2-medal { background: #64748b; }
.lb2-bronze .lb2-medal { background: #c2410c; }

.lb2-podium-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: #0f172a;
}

.lb2-podium-points {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 10px;
  font-variant-numeric: tabular-nums;
}

.lb2-podium-points span {
  font-size: 0.75rem;
  font-weight: 500;
  color: #64748b;
}

.lb2-podium-step {
  width: 100%;
  border-radius: 12px 12px 4px 4px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10px;
  font-size: 1.4rem;
  font-weight: 800;
}

.lb2-gold .lb2-podium-step {
  height: 96px;
  color: #b45309;
  background: linear-gradient(180deg, #fef3c7, #fffbeb);
  border: 1px solid #fde68a;
}

.lb2-silver .lb2-podium-step {
  height: 68px;
  color: #475569;
  background: linear-gradient(180deg, #e2e8f0, #f8fafc);
  border: 1px solid #cbd5e1;
}

.lb2-bronze .lb2-podium-step {
  height: 48px;
  color: #9a3412;
  background: linear-gradient(180deg, #ffedd5, #fff7ed);
  border: 1px solid #fed7aa;
}

/* Ranking list */
.lb2-list-head,
.lb2-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 80px 90px;
  align-items: center;
  gap: 12px;
}

.lb2-list-head {
  padding: 0 16px 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #94a3b8;
}

.lb2-list-head span:nth-child(3),
.lb2-list-head span:nth-child(4) { text-align: right; }

.lb2-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lb2-row {
  padding: 12px 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.lb2-row:hover {
  border-color: #c7d2fe;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
  transform: translateY(-1px);
}

.lb2-row-me {
  background: var(--brand-wash);
  border-color: #c4b5fd;
  box-shadow: inset 4px 0 0 #8b5cf6;
}

.lb2-rank {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 800;
  color: #475569;
  background: #f1f5f9;
}

.lb2-rank-gold   { background: #fef3c7; color: #b45309; box-shadow: inset 0 0 0 1.5px #fbbf24; }
.lb2-rank-silver { background: #f1f5f9; color: #475569; box-shadow: inset 0 0 0 1.5px #94a3b8; }
.lb2-rank-bronze { background: #ffedd5; color: #9a3412; box-shadow: inset 0 0 0 1.5px #fb923c; }

.lb2-student {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.lb2-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
}

.lb2-student-text { min-width: 0; flex: 1; }

.lb2-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb2-you {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--brand-gradient);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  vertical-align: 1px;
}

.lb2-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}

.lb2-progress-bar {
  flex: 1;
  max-width: 220px;
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.lb2-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand-gradient);
}

.lb2-progress span {
  font-size: 0.75rem;
  color: #64748b;
  white-space: nowrap;
}

.lb2-quizzes {
  text-align: right;
  font-size: 0.95rem;
  font-weight: 600;
  color: #475569;
  font-variant-numeric: tabular-nums;
}

.lb2-points {
  text-align: right;
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  font-variant-numeric: tabular-nums;
}

.lb2-points small {
  margin-left: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  color: #64748b;
}

/* Dark mode */
body.dark-mode .lb2-title,
body.dark-mode .lb2-me-rank,
body.dark-mode .lb2-podium-name,
body.dark-mode .lb2-podium-points,
body.dark-mode .lb2-name,
body.dark-mode .lb2-points { color: #f1f5f9; }

body.dark-mode .lb2-subtitle,
body.dark-mode .lb2-me-hint,
body.dark-mode .lb2-quizzes { color: #94a3b8; }

body.dark-mode .lb2-me {
  background: var(--brand-wash-dark);
  border-color: var(--brand-border-dark);
}

body.dark-mode .lb2-me-label { color: #c4b5fd; }
body.dark-mode .lb2-me-avatar { box-shadow: 0 0 0 3px #0f172a, 0 0 0 5px #8b5cf6; }

body.dark-mode .lb2-row {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .lb2-row:hover { border-color: rgba(167, 139, 250, 0.45); }

body.dark-mode .lb2-row-me {
  background: linear-gradient(90deg, rgba(6, 182, 212, 0.12), rgba(124, 58, 237, 0.18));
  border-color: rgba(167, 139, 250, 0.45);
}

body.dark-mode .lb2-rank { background: #334155; color: #cbd5e1; }
body.dark-mode .lb2-progress-bar { background: #334155; }
body.dark-mode .lb2-podium-avatar { border-color: #0f172a; }
body.dark-mode .lb2-medal { border-color: #0f172a; }
body.dark-mode .lb2-gold .lb2-podium-step   { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.35); color: #fbbf24; }
body.dark-mode .lb2-silver .lb2-podium-step { background: rgba(148, 163, 184, 0.14); border-color: rgba(148, 163, 184, 0.35); color: #cbd5e1; }
body.dark-mode .lb2-bronze .lb2-podium-step { background: rgba(194, 65, 12, 0.16); border-color: rgba(251, 146, 60, 0.35); color: #fdba74; }

/* Phones */
@media (max-width: 640px) {
  .lb2-me { flex-wrap: wrap; }
  .lb2-me-points { align-items: flex-start; padding: 0; }
  .lb2-me-btn { width: 100%; text-align: center; }
  .lb2-podium { gap: 8px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lb2-podium-avatar { width: 52px; height: 52px; }
  .lb2-gold .lb2-podium-avatar { width: 64px; height: 64px; }
  .lb2-list-head, .lb2-row { grid-template-columns: 36px minmax(0, 1fr) 64px; gap: 10px; }
  .lb2-hide-sm { display: none; }
  .lb2-progress-bar { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  .lb2-row, .lb2-me-btn { transition: none; }
  .lb2-row:hover, .lb2-me-btn:hover { transform: none; }
}
