*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: rgba(168, 85, 247, 0.35) var(--bg-primary);
}

/* GLOBAL SCROLLBARS (WEBKIT) */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(168, 85, 247, 0.35);
  border-radius: 10px;
  border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(168, 85, 247, 0.6);
}

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-sidebar: #16162a;
  --bg-card: #1e1e34;
  --bg-hover: #252545;
  --bg-active: #2a2a50;
  --text-primary: #e8e8f0;
  --text-secondary: #9898b8;
  --text-muted: #686888;
  --accent: #a855f7;
  --accent-hover: #9333ea;
  --accent-dim: rgba(168, 85, 247, 0.15);
  --border: #2a2a45;
  --success: #22c55e;
  --shadow: rgba(0, 0, 0, 0.4);
  --header-height: 56px;
  --sidebar-width: 340px;
  --radius: 8px;
  --radius-sm: 4px;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* HEADER */
#header {
  height: var(--header-height);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
  z-index: 100;
}

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

#sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

#sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.course-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

#progress-indicator {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* LAYOUT */
#layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* SIDEBAR */
#sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left 0.3s ease;
}

#sidebar.collapsed {
  margin-left: calc(-1 * var(--sidebar-width));
}

#sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.4;
  background: rgba(0, 0, 0, 0.15);
}

.sidebar-footer span {
  color: var(--accent);
  font-weight: 500;
}

.week-group {
  border-bottom: 1px solid var(--border);
}

.week-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.week-header:hover {
  background: var(--bg-hover);
}

.week-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.week-number {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.week-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.week-chevron {
  color: var(--text-muted);
  transition: transform 0.2s;
  display: flex;
}

.week-chevron.open {
  transform: rotate(180deg);
}

.week-lectures {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.week-lectures.open {
  max-height: 2000px;
}

.lecture-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 28px;
  cursor: pointer;
  transition: background 0.15s;
  border-left: 3px solid transparent;
}

.lecture-item:hover {
  background: var(--bg-hover);
}

.lecture-item.active {
  background: var(--accent-dim);
  border-left-color: var(--accent);
}

.lecture-status {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.lecture-status.watched {
  color: var(--success);
}

.lecture-status.current {
  color: var(--accent);
}

.lecture-num {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  min-width: 24px;
  flex-shrink: 0;
}

.lecture-item.active .lecture-num {
  color: var(--accent);
}

.lecture-title-sidebar {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.lecture-item.active .lecture-title-sidebar {
  color: var(--text-primary);
}

.lecture-duration {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
  flex-shrink: 0;
}

/* MAIN */
#main {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-primary);
}

#lecture-view {
  max-width: 960px;
  margin: 0 auto;
  padding: 24px;
}

/* VIDEO CONTAINER */
#video-container {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 16 / 9;
  max-height: 540px;
}

#video-player {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

#video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
  transition: opacity 0.3s;
  z-index: 5;
}

#video-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

#big-play-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  box-shadow: 0 4px 20px rgba(168, 85, 247, 0.4);
}

#big-play-btn:hover {
  transform: scale(1.08);
  background: var(--accent-hover);
}

/* CUSTOM CONTROLS */
#custom-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  padding: 32px 12px 8px;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.3s;
}

#video-container:hover #custom-controls,
#video-container.show-controls #custom-controls {
  opacity: 1;
}

#progress-bar {
  position: relative;
  height: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.15);
}

#progress-bar:hover {
  height: 8px;
  border-radius: 4px;
}

#progress-buffer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: rgba(255, 255, 255, 0.2);
  border-radius: inherit;
}

#progress-current {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  z-index: 1;
}

#progress-thumb {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  display: none;
}

#progress-bar:hover #progress-thumb {
  display: block;
}

#progress-slider {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 3;
  width: 100%;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.controls-left, .controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.control-btn {
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.control-btn:hover {
  color: var(--accent);
}

#speed-btn {
  font-size: 12px;
  font-weight: 600;
  min-width: 32px;
}

#volume-slider {
  width: 70px;
  height: 4px;
  accent-color: var(--accent);
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  cursor: pointer;
}

#time-display {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
  font-variant-numeric: tabular-nums;
  margin-left: 6px;
}

/* LECTURE INFO */
#lecture-info {
  margin-top: 20px;
}

#lecture-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
  line-height: 1.3;
}

#lecture-description {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.7;
}

#lecture-description h1,
#lecture-description h2,
#lecture-description h3 {
  color: var(--text-primary);
  margin: 20px 0 10px;
}

#lecture-description h1 { font-size: 22px; }
#lecture-description h2 { font-size: 18px; }
#lecture-description h3 { font-size: 16px; }

#lecture-description p {
  margin-bottom: 12px;
}

#lecture-description ul, #lecture-description ol {
  margin: 8px 0 12px 24px;
}

#lecture-description li {
  margin-bottom: 4px;
}

#lecture-description a {
  color: var(--accent);
  text-decoration: none;
}

#lecture-description a:hover {
  text-decoration: underline;
}

#lecture-description code {
  background: var(--bg-card);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 14px;
  color: var(--accent);
}

#lecture-description pre {
  background: var(--bg-card);
  padding: 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  margin: 12px 0;
  border: 1px solid var(--border);
}

#lecture-description img {
  max-width: 100%;
  border-radius: var(--radius);
  margin: 12px 0;
}

/* NAV */
#lecture-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
}

.nav-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}

.nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

#nav-position {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

/* WELCOME VIEW */
#welcome-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 40px;
}

#welcome-view.hidden {
  display: none;
}

.welcome-content {
  text-align: center;
  max-width: 500px;
}

.welcome-icon {
  color: var(--accent);
  margin-bottom: 24px;
  opacity: 0.8;
}

.welcome-content h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 12px;
}

.welcome-content p {
  color: var(--text-secondary);
  font-size: 16px;
  margin-bottom: 24px;
}

.welcome-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  text-align: center;
}

.stat-number {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* SCROLLBAR */
#sidebar::-webkit-scrollbar,
#main::-webkit-scrollbar {
  width: 6px;
}

#sidebar::-webkit-scrollbar-track,
#main::-webkit-scrollbar-track {
  background: transparent;
}

#sidebar::-webkit-scrollbar-thumb,
#main::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover,
#main::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* LOADING */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* TRANSCRIPTION PANEL */
#transcription-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  position: relative;
}

#transcription-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

#transcription-badge {
  position: absolute;
  top: 0;
  right: -2px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  padding: 0 4px;
}

#transcription-panel {
  position: fixed;
  top: var(--header-height);
  right: 8px;
  width: 365px;
  max-height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px var(--shadow);
  z-index: 200;
  display: flex;
  flex-direction: column;
}

#transcription-panel.hidden {
  display: none;
}

.transcription-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-sidebar);
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  flex-shrink: 0;
}

.transcription-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 12px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
  border-bottom: 2px solid transparent;
}

.transcription-tab:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.transcription-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--bg-card);
}

#transcription-list {
  flex: 1;
  overflow-y: auto;
}

#transcription-list::-webkit-scrollbar {
  width: 6px;
}

#transcription-list::-webkit-scrollbar-track {
  background: transparent;
}

#transcription-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

#transcription-list::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

.transcription-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

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

.transcription-item-title {
  color: var(--text-primary);
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transcription-item-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.transcription-item .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.transcription-item .status-dot.queued {
  background: var(--text-muted);
}

.transcription-item .status-dot.transcribing {
  background: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

.transcription-item .status-dot.completed {
  background: var(--success);
}

.transcription-item .status-dot.failed {
  background: #ef4444;
}

.transcription-item .status-label {
  color: var(--text-secondary);
}

.transcription-view-link {
  margin-left: auto;
  color: var(--accent);
  text-decoration: none;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 2px 6px;
  border-radius: 3px;
  transition: background 0.15s;
}

.transcription-view-link:hover {
  background: var(--accent-dim);
}

.transcription-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* CC BUTTON */
#cc-btn {
  position: relative;
}

#cc-btn.cc-off {
  opacity: 0.5;
}

#cc-btn.cc-on {
  color: var(--accent);
  opacity: 1;
}

/* CAPTIONS SECTION */
#captions-section {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

#captions-status {
  font-size: 13px;
  color: var(--text-muted);
}

#gen-captions-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s;
}

#gen-captions-btn:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--accent);
}

#gen-captions-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#gen-captions-btn .spinner-small {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* SUBTITLE DISPLAY */
#subtitle-display {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  text-align: center;
  pointer-events: none;
  z-index: 8;
  padding: 0 48px;
  opacity: 0;
  transition: opacity 0.15s;
}

#subtitle-display.active {
  opacity: 1;
}

#subtitle-display > span {
  display: inline-block;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  padding: 4px 12px;
  border-radius: 4px;
  max-width: 80%;
}

/* VIDEO LOADER / BUFFERING SPINNER */
#video-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  z-index: 6;
  transition: opacity 0.2s;
  pointer-events: none;
}

#video-loader.hidden {
  opacity: 0;
}

.video-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* FEATURES LINK */
#features-link {
  color: var(--text-secondary);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

#features-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* RESPONSIVE */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 50;
    box-shadow: 2px 0 20px var(--shadow);
  }

  #sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
  }

  #lecture-view {
    padding: 12px;
  }

  #lecture-title {
    font-size: 17px;
  }
}

/* CHATBOT WIDGET */
#chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, #9333ea 100%);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

#chat-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.6);
}

#chat-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 360px;
  height: 480px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 40px var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.2s, transform 0.2s;
  transform-origin: bottom right;
}

#chat-window.hidden {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}

#chat-header {
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text-primary);
}

#chat-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

#chat-close:hover {
  color: var(--text-primary);
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

#chat-reset {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, transform 0.25s ease;
}

#chat-reset:hover {
  color: var(--text-primary);
  transform: rotate(180deg);
}

#chat-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chat-messages::-webkit-scrollbar {
  width: 4px;
}

#chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.chat-message {
  display: flex;
  max-width: 85%;
}

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
}

.chat-message-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13.5px;
  line-height: 1.45;
  white-space: pre-line;
}

.chat-message.bot .chat-message-bubble {
  background: var(--bg-sidebar);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border);
}

.chat-message.user .chat-message-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 2px;
}

.chat-link {
  color: var(--accent);
  text-decoration: underline;
}

.chat-link:hover {
  color: var(--text-primary);
}

/* Markdown Render Styles in Chat */
.chat-message-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0;
  font-size: 12px;
}

.chat-message-bubble th, .chat-message-bubble td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}

.chat-message-bubble th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
}

.chat-message-bubble h1, .chat-message-bubble h2, .chat-message-bubble h3 {
  margin: 12px 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.chat-message-bubble ul, .chat-message-bubble ol {
  margin-left: 20px;
  margin-bottom: 8px;
}

.chat-message-bubble li {
  margin-bottom: 4px;
  font-size: 13px;
}

.chat-message-bubble p {
  margin-bottom: 8px;
}

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

.chat-message-bubble code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 4px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 12px;
}

.chat-message-bubble pre {
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 10px 0;
  border: 1px solid var(--border);
}

.chat-message-bubble pre code {
  background: none;
  padding: 0;
  border-radius: 0;
}

#chat-input-container {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  background: var(--bg-sidebar);
}

#chat-input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

#chat-input:focus {
  border-color: var(--accent);
}

#chat-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

#chat-send:hover {
  background: #9333ea;
}

/* Thinking Indicator */
.chat-thinking {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px 8px;
}

.chat-thinking span {
  width: 6px;
  height: 6px;
  background: var(--text-secondary);
  border-radius: 50%;
  animation: chatPulse 1.2s infinite;
}

.chat-thinking span:nth-child(2) { animation-delay: 0.2s; }
.chat-thinking span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatPulse {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* --- QUIZ FEATURES SYSTEM STYLE --- */
#quiz-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(147, 51, 234, 0.15);
  border: 1px solid rgba(147, 51, 234, 0.3);
  color: #c084fc;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
}

#quiz-toggle:hover {
  background: rgba(147, 51, 234, 0.3);
  border-color: #a855f7;
  color: #fff;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.2);
}

#quiz-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.3s ease;
}

#quiz-modal-content {
  background: rgba(18, 12, 28, 0.95);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 16px;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.1);
  display: flex;
  flex-direction: column;
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
  0% { transform: scale(0.9) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

#quiz-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

#quiz-modal-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  background: linear-gradient(135deg, #c084fc 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#quiz-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
  position: relative;
  z-index: 10;
}

#quiz-modal-close:hover {
  color: #ef4444;
}

/* VIEW 1: MENU STYLE */
#quiz-menu-view {
  padding: 24px;
}

.quiz-welcome-text {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 24px;
}

.quiz-menu-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 30px;
}

.quiz-action-btn {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #fff;
  padding: 14px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.quiz-action-btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(124, 58, 237, 0.4);
  border-color: #a855f7;
}

.quiz-action-btn:active:not(:disabled) {
  transform: translateY(0);
}

.quiz-action-btn.secondary {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border);
  color: var(--text-primary);
}

.quiz-action-btn.secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: var(--text-secondary);
  box-shadow: none;
}

.quiz-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.quiz-history-section h4 {
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

#quiz-history-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 4px;
}

.no-history-text {
  color: var(--text-secondary);
  font-size: 13px;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

.quiz-history-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s;
}

.quiz-history-item:hover {
  background: rgba(147, 51, 234, 0.05);
  border-color: rgba(147, 51, 234, 0.3);
}

.history-item-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.history-item-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.history-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
}

.history-item-score {
  font-size: 13px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
}

.history-item-score.pass {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.history-item-score.fail {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

/* VIEW 2: QUESTION PANEL STYLE */
#quiz-question-view {
  padding: 24px;
}

.quiz-progress-container {
  margin-bottom: 20px;
}

#quiz-progress-text {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.quiz-progress-bar-bg {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 3px;
  overflow: hidden;
}

#quiz-progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #a855f7, #ec4899);
  width: 0%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#quiz-question-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 20px;
}

#quiz-options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 24px;
}

.quiz-option-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.2s;
  font-size: 13.5px;
  color: var(--text-primary);
  position: relative;
}

.quiz-option-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.2);
}

.quiz-option-card input[type="radio"] {
  accent-color: #a855f7;
  width: 16px;
  height: 16px;
}

.quiz-option-card.selected {
  background: rgba(147, 51, 234, 0.08);
  border-color: #a855f7;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.1);
}

.quiz-footer-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

/* VIEW 3: RESULTS PANEL STYLE */
#quiz-results-view {
  padding: 24px;
}

.quiz-score-ring-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 26px;
}

.quiz-score-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: conic-gradient(#a855f7 0%, #ec4899 var(--score-percent, 0%), rgba(255, 255, 255, 0.05) var(--score-percent, 0%) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px rgba(168, 85, 247, 0.15);
  margin-bottom: 12px;
  position: relative;
}

.quiz-score-ring::after {
  content: '';
  position: absolute;
  top: 6px;
  left: 6px;
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: rgba(18, 12, 28, 0.95);
  z-index: 1;
}

.quiz-score-ring span {
  position: relative;
  z-index: 2;
}

#quiz-score-fraction {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.quiz-score-label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1px;
}

#quiz-grade-text {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

#quiz-review-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 26px;
  padding-right: 4px;
}

.quiz-review-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.quiz-review-q-header {
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.quiz-review-q-header:hover {
  background: rgba(255, 255, 255, 0.02);
}

.quiz-review-q-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quiz-review-chevron {
  display: flex;
  align-items: center;
  transition: transform 0.2s;
  color: var(--text-muted);
}

.quiz-review-item.collapsed .quiz-review-chevron {
  transform: rotate(-90deg);
}

.quiz-review-item.collapsed .quiz-review-q-body {
  display: none !important;
}

.quiz-review-item.correct {
  border-color: rgba(34, 197, 94, 0.3);
}

.quiz-review-item.correct .quiz-review-q-header {
  background: rgba(34, 197, 94, 0.05);
  color: #4ade80;
}

.quiz-review-item.incorrect {
  border-color: rgba(239, 68, 68, 0.3);
}

.quiz-review-item.incorrect .quiz-review-q-header {
  background: rgba(239, 68, 68, 0.05);
  color: #f87171;
}

.quiz-review-q-body {
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.01);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quiz-review-choice {
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.quiz-review-choice.user-selected {
  font-weight: 600;
}

.quiz-review-choice.user-selected.correct {
  color: #4ade80;
}

.quiz-review-choice.user-selected.incorrect {
  color: #f87171;
}

.quiz-review-choice.correct-answer {
  color: #4ade80;
  font-weight: 600;
}

.quiz-review-explanation {
  font-size: 12px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  border-radius: 6px;
  line-height: 1.45;
  border-left: 3px solid #a855f7;
  margin-top: 6px;
}

.quiz-results-footer {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

/* LOADING SPINNER FOR QUIZ */
.quiz-loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 0;
  gap: 16px;
}

.quiz-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(168, 85, 247, 0.1);
  border-radius: 50%;
  border-top-color: #a855f7;
  animation: quizSpin 1s linear infinite;
}

@keyframes quizSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Global hidden class helper */
.hidden {
  display: none !important;
}

/* MCQ Options Review styling */
.quiz-review-options-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  margin-top: 6px;
}

.quiz-review-option-item {
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(255, 255, 255, 0.01);
  color: var(--text-secondary);
  transition: all 0.2s ease;
}

.quiz-review-option-item.correct-choice {
  border-color: rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.08);
  color: #4ade80;
  font-weight: 500;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.08);
}

.quiz-review-option-item.incorrect-choice {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
  color: #f87171;
  font-weight: 500;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.08);
}

.option-icon {
  font-weight: bold;
  font-size: 14px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* --- AUTH SYSTEM STYLE --- */
#auth-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(147, 51, 234, 0.15);
  border: 1px solid rgba(147, 51, 234, 0.3);
  color: #c084fc;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
}

#auth-toggle:hover {
  background: rgba(147, 51, 234, 0.3);
  border-color: #a855f7;
  color: #fff;
}

#user-badge {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#auth-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#auth-modal-content {
  background: rgba(18, 12, 28, 0.95);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 16px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.1);
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#auth-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

#auth-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  background: linear-gradient(135deg, #c084fc 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#auth-modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#login-form, #request-access-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#request-access-pending {
  text-align: center;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

#request-access-pending .quiz-action-btn {
  margin: 16px auto 0;
  display: inline-flex;
  width: auto;
  padding: 8px 18px;
}

.auth-input {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}

.auth-input:focus {
  border-color: #a855f7;
}

#auth-error-text {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #f87171;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

#auth-switch-text {
  text-align: center;
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

#auth-switch-text a {
  color: #c084fc;
  cursor: pointer;
  text-decoration: none;
}

#auth-switch-text a:hover {
  text-decoration: underline;
}

#admin-dashboard-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: all 0.2s ease;
}

#admin-dashboard-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-secondary);
}

#admin-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#admin-modal-content {
  background: rgba(18, 12, 28, 0.95);
  border: 1px solid rgba(147, 51, 234, 0.3);
  border-radius: 16px;
  width: 90%;
  max-width: 720px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 30px rgba(168, 85, 247, 0.1);
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#admin-modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
  position: sticky;
  top: 0;
}

#admin-modal-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  background: linear-gradient(135deg, #c084fc 0%, #a855f7 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

#admin-modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}

#admin-modal-close:hover {
  color: #ef4444;
}

#admin-modal-body {
  padding: 16px 24px 24px;
  overflow-x: auto;
}

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-users-table th {
  text-align: left;
  padding: 8px 10px;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.admin-users-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  white-space: nowrap;
}

.admin-users-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.status-badge.pending {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

.status-badge.approved {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
}

.status-badge.rejected {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.admin-actions-cell {
  vertical-align: middle;
}

.admin-request-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-request-actions .quiz-action-btn {
  padding: 6px 14px;
  font-size: 13px;
  white-space: nowrap;
}

.admin-no-action {
  color: var(--text-muted, rgba(255, 255, 255, 0.4));
  font-size: 14px;
  display: inline-block;
}

#admin-dashboard-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible !important;
}

.admin-pending-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  background: linear-gradient(160deg, #fb7185 0%, #dc2626 100%);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  border: 2px solid var(--bg-secondary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  z-index: 10;
}

.admin-pending-badge::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid #f43f5e;
  animation: admin-badge-ring 2.6s cubic-bezier(0.2, 0.6, 0.4, 1) infinite;
}

.admin-pending-badge.hidden {
  display: none !important;
}

@keyframes admin-badge-ring {
  0% {
    transform: scale(0.8);
    opacity: 0.6;
  }
  70%, 100% {
    transform: scale(1.7);
    opacity: 0;
  }
}

#admin-reports-btn {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25) 0%, rgba(139, 92, 246, 0.25) 100%);
  border: 1px solid rgba(168, 85, 247, 0.5);
  color: #e9d5ff;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius, 8px);
  cursor: pointer !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(168, 85, 247, 0.15);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#admin-reports-btn:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.45) 0%, rgba(139, 92, 246, 0.45) 100%);
  border-color: #a855f7;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.35);
  transform: translateY(-1px);
  cursor: pointer !important;
}

#admin-reports-link {
  text-decoration: none;
  cursor: pointer;
}

#admin-quiz-banks-btn {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25) 0%, rgba(14, 165, 233, 0.25) 100%);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: #bae6fd;
  font-weight: 600;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--radius, 8px);
  cursor: pointer !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 10px rgba(56, 189, 248, 0.15);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#admin-quiz-banks-btn:hover {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.45) 0%, rgba(14, 165, 233, 0.45) 100%);
  border-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
  cursor: pointer !important;
}

#admin-quiz-banks-link {
  text-decoration: none;
  cursor: pointer;
}

/* ADMIN QUIZ REPORTS MODAL & ANALYTICS */
#admin-reports-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#admin-reports-modal-content {
  background: var(--bg-card, #14151f);
  border: 1px solid var(--border, rgba(255, 255, 255, 0.12));
  border-radius: 16px;
  width: 100%;
  max-width: 800px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

#admin-reports-modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border, rgba(255, 255, 255, 0.1));
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#admin-reports-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary, #f3f4f6);
}

#admin-reports-modal-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 22px;
  cursor: pointer;
}

#admin-reports-modal-close:hover {
  color: #fff;
}

#admin-reports-modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-quiz-filter-bar input {
  width: 100%;
  box-sizing: border-box;
}

.admin-quiz-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.stat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}

.stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #8b5cf6;
  margin-bottom: 4px;
}

.stat-title {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* TOAST / SNACKBAR NOTIFICATION CONTAINER */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 420px;
  width: calc(100vw - 48px);
}

.toast-item {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(20, 21, 31, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  padding: 12px 16px;
  border-radius: 12px;
  color: #f3f4f6;
  font-size: 14px;
  line-height: 1.4;
  transform: translateY(20px) scale(0.95);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-item.show {
  transform: translateY(0) scale(1);
  opacity: 1;
}

.toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  font-size: 14px;
  font-weight: 700;
}

.toast-item.success .toast-icon {
  background: rgba(16, 185, 129, 0.2);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.toast-item.error .toast-icon {
  background: rgba(244, 63, 94, 0.2);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.4);
}

.toast-item.info .toast-icon {
  background: rgba(139, 92, 246, 0.2);
  color: #8b5cf6;
  border: 1px solid rgba(139, 92, 246, 0.4);
}

.toast-item.warning .toast-icon {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.toast-content {
  flex: 1;
  word-break: break-word;
}

.toast-close {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.toast-close:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

/* --- INTERACTIVE LECTURE DESCRIPTION (compact, tabbed) --- */
.idesc-container {
  display: flex;
  flex-direction: column;
  background: rgba(18, 19, 31, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin-top: 14px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
}

/* Tab bar */
.idesc-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.idesc-tab {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, background 0.15s ease;
}

.idesc-tab:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.04);
}

.idesc-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.idesc-tab-count {
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(139, 92, 246, 0.18);
  color: #d8b4fe;
  padding: 1px 6px;
  border-radius: 10px;
}

/* Panels */
.idesc-panels {
  position: relative;
  overflow: hidden;
  transition: height 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.idesc-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px 16px;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.idesc-panel[hidden] {
  display: none;
}

.idesc-panel.idesc-fade {
  opacity: 0;
  transform: translateY(6px);
}

.idesc-overview-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.idesc-overview-points {
  margin-top: 12px;
}

.idesc-overview-points li {
  font-size: 13px;
}

/* KEY CONCEPTS: jump pills + accordion */
.concept-badges-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.concept-tag-badge {
  background: rgba(139, 92, 246, 0.14);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #d8b4fe;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  text-decoration: none;
  transition: all 0.15s ease;
}

.concept-tag-badge:hover {
  background: rgba(139, 92, 246, 0.3);
  border-color: #a855f7;
  color: #fff;
}

.topics-linear-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.topic-detail-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  overflow: hidden;
}

.topic-detail-card[open] {
  border-color: rgba(168, 85, 247, 0.35);
}

.topic-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
}

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

.topic-summary-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.topic-name {
  font-size: 13.5px;
  font-weight: 700;
  color: #fff;
}

.topic-simple-def {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.topic-chevron {
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.topic-detail-card[open] .topic-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.topic-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding-top: 10px;
}

.topic-breakdown {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
}

.topic-analogy {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 8px 12px;
  border-radius: 8px;
  color: #fef08a;
  font-size: 12px;
  line-height: 1.45;
}

/* Scannable bullet points inside a concept card */
.topic-points {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.topic-points li {
  position: relative;
  padding-left: 16px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.topic-points li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.topic-example {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 8px 12px;
  border-radius: 8px;
  color: #bae6fd;
  font-size: 12px;
  line-height: 1.45;
}

.topic-breakdown code,
.topic-points code,
.topic-example code {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: 'Fira Code', monospace, Consolas;
  font-size: 0.95em;
  color: #38bdf8;
}

.topic-example code {
  color: #7dd3fc;
  background: rgba(255, 255, 255, 0.1);
}

/* 8-stages / N-stages breakdown */
.topic-stages-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stage-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 8px 10px;
}

.stage-step-item.sweet-spot {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.35);
}

.stage-step-badge {
  font-size: 10.5px;
  font-weight: 700;
  color: #c084fc;
  background: rgba(192, 132, 252, 0.15);
  border: 1px solid rgba(192, 132, 252, 0.3);
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.stage-step-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 12.5px;
}

.stage-step-title {
  color: #ffffff;
  font-weight: 600;
}

.stage-step-desc {
  color: var(--text-secondary);
  font-size: 12px;
}

/* PRACTICAL OUTCOME */
.achievement-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.12) 0%, rgba(139, 92, 246, 0.12) 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 10px;
  padding: 12px 14px;
}

.achievement-icon {
  font-size: 19px;
  line-height: 1;
}

.achievement-content h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: #10b981;
  margin-bottom: 4px;
}

.achievement-content p {
  font-size: 12.5px;
  line-height: 1.5;
  color: #e5e7eb;
}

.section-sub-header h4 {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent);
  margin: 4px 0 0;
}

/* PROMPTS */
.prompts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-block-card {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.prompt-block-card pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: 'Fira Code', monospace, Consolas;
  font-size: 12px;
  color: #e2e8f0;
}

/* COMMANDS */
.commands-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.command-block-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.command-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.command-code-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: rgba(15, 16, 26, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 7px 10px;
  border-radius: 7px;
  overflow-x: auto;
}

.command-code-row code {
  font-family: 'Fira Code', monospace, Consolas;
  font-size: 12.5px;
  color: #38bdf8;
  white-space: nowrap;
}

.copy-cmd-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
  flex-shrink: 0;
  align-self: flex-start;
}

.copy-cmd-btn:hover {
  background: rgba(139, 92, 246, 0.25);
  border-color: var(--accent);
}

.copy-cmd-btn.copied {
  background: rgba(16, 185, 129, 0.25);
  border-color: #10b981;
  color: #10b981;
}

/* RESOURCES */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.resource-link-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.resource-link-card:hover {
  background: rgba(139, 92, 246, 0.15);
  border-color: rgba(139, 92, 246, 0.4);
  transform: translateY(-1px);
}

.resource-title {
  font-size: 12.5px;
  font-weight: 600;
  flex: 1;
  padding-right: 8px;
}

