/* CSS Variables & Reset */
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --bg-app: #F3F4F6;
  --bg-card: #FFFFFF;
  --text-main: #111827;
  --text-muted: #6B7280;
  --border: #E5E7EB;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --radius: 0.75rem;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --font-main: 'Inter', sans-serif;
}

body.dark-mode {
  --bg-app: #090d15;
  --bg-card: #161b22;
  --text-main: #F9FAFB;
  --text-muted: #9CA3AF;
  --border: #30363d;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-app);
  color: var(--text-main);
  margin: 0;
  line-height: 1.5;
  transition: background-color 0.3s, color 0.3s;
  overflow-x: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Layout */
.main-header {
  background: var(--bg-card);
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

.logo {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.nav-link {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.nav-link:hover {
  background-color: rgba(79, 70, 229, 0.1);
  color: var(--primary);
}

#main-content {
  max-width: 1000px;
  margin: 2rem auto;
  padding: 0 1rem;
}

/* UI Components */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all 0.2s;
  gap: 0.5rem;
  white-space: normal;
  text-align: center;
  min-width: fit-content;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: white;
  color: var(--text-main);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-app);
  border-color: var(--text-muted);
}

.btn-danger {
  background: #FEE2E2;
  color: #991B1B;
}

.btn-danger:hover {
  background: #FECACA;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-app);
  color: var(--text-main);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1.7rem;
  box-shadow: var(--shadow);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: 0.375rem;
  font-family: inherit;
  margin-bottom: 0.5rem;
}

/* Guest Banner */
.guest-banner {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-app) 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.guest-icon {
  font-size: 2.5rem;
  background: rgba(79, 70, 229, 0.1);
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.guest-text {
  flex: 1;
}

.guest-text h3 {
  margin: 0 0 0.5rem 0;
  color: var(--primary);
  font-size: 1.25rem;
}

.guest-text p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .guest-banner {
    flex-direction: column;
    text-align: center;
  }

  .guest-icon {
    margin: 0 auto;
  }

  .guest-banner .btn {
    width: 100%;
  }
}

body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="file"],
body.dark-mode textarea,
body.dark-mode select {
  background-color: var(--bg-card);
  border-color: var(--border);
  color: var(--text-main);
}

.editor-card {
  background: #eff6ff;
  border: 1px solid #dbeafe;
}

body.dark-mode .editor-card {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .btn-secondary {
  background: transparent;
  color: var(--text-main);
  border-color: var(--border);
}

body.dark-mode .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.dark-mode .btn-outline {
  color: var(--text);
  border-color: var(--border);
}

body.dark-mode .btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
}

textarea {
  resize: vertical;
  min-height: 80px;
}

/* Deck Grid */
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.deck-card {
  cursor: pointer;
  transition: transform 0.2s;
  border-top: 4px solid var(--primary);
  display: flex;
  flex-direction: column;
  height: 100%;
  justify-content: space-between;
}

.sidebar-footer {
  margin-top: auto;
  order: 999;
}

.deck-card:hover {
  transform: translateY(-2px);
}

/* Profile Section in Sidebar */
.profile-section {
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  order: 1000;
}

.avatar-circle {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  flex-shrink: 0;
}

.profile-info {
  overflow: hidden;
}

.profile-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-role {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.mastery-container {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.mastery-bar {
  height: 6px;
  background: #E5E7EB;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 4px;
}

.mastery-fill {
  height: 100%;
  transition: width 0.5s ease;
}

.mastery-text {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Editor List */
.card-list-item {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  align-items: start;
}

.card-preview {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--bg-app);
}

/* Study Mode */
.flashcard-container {
  perspective: 1000px;
  height: 500px;
  margin-bottom: 2rem;
  cursor: pointer;
}

.flashcard {
  position: relative;
  width: 100%;
  height: 100%;
  text-align: center;
  transition: transform 0.6s;
  transform-style: preserve-3d;
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  background: var(--bg-card);
}

.flashcard.flipped {
  transform: rotateY(180deg);
}

.flashcard-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  overflow: hidden;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: var(--bg-card);
}

.flashcard-content {
  width: 100%;
  max-width: 100%;
  word-wrap: break-word;
}

.flashcard-content img {
  width: 100%;
  height: 250px;
  object-fit: contain;
  margin-bottom: 1rem;
  border-radius: 0.5rem;
}

.flashcard-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  width: 100%;
  scrollbar-width: thin;
}

.flashcard-text {
  font-size: 1.5rem;
  font-weight: 500;
  text-align: center;
  line-height: 1.5;
  color: var(--text-main);
  /* Fix for long text overflow */
  overflow-wrap: anywhere;
  word-break: break-word;
  max-width: 100%;
}

.rating-bar {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.rate-btn {
  flex: 1;
  padding: 1rem;
  border: none;
  border-radius: 0.5rem;
  font-weight: 700;
  color: white;
  transition: transform 0.1s;
}

.rate-btn:hover {
  transform: scale(1.05);
}

/* Rating Colors */
.rate-1 {
  background: #EF4444;
}

.rate-2 {
  background: #F59E0B;
}

.rate-3 {
  background: #EAB308;
}

.rate-4 {
  background: #84CC16;
}

.rate-5 {
  background: #22C55E;
}

/* --- Modern Minimal Polish (Violet untouched) --- */

/* 1. Smoother card and sidebar shadows for depth */
.card,
.dashboard-sidebar,
.deck-card,
.flashcard {
  box-shadow: 0 6px 32px 0 rgba(16, 16, 32, 0.10), 0 1.5px 4px 0 rgba(0, 0, 0, 0.10);
}

/* 2. Headings: bolder, more modern */
h1,
h2,
h3 {
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-bottom: 0.5em;
}

/* 3. Inputs: cleaner, more padding, subtle focus */
input,
select,
textarea {
  padding: 0.9rem 1.1rem;
  font-size: 1.05rem;
  border-radius: 0.7rem;
  border: 1.5px solid var(--border);
  transition: border 0.18s, box-shadow 0.18s;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.08);
}

/* 4. Buttons: slightly larger, bolder */
.btn {
  font-size: 1.08rem;
  padding: 0.7rem 1.3rem;
  border-radius: 0.7rem;
}

/* 5. Sidebar: more spacing, less clutter */
.dashboard-sidebar {
  gap: 1rem;
  padding: 2rem 1.2rem;
}

/* 6. Sidebar links: more readable, less muted */
.sidebar-link,
.nav-link.sidebar-link {
  font-size: 1.07rem;
  font-weight: 600;
  color: var(--text-main);
}

/* 7. Footer: cleaner, more contrast */
.main-footer {
  background: var(--bg-card);
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  font-size: 1rem;
  padding: 2rem 1rem;
}

/* 8. Deck cards: more radius, subtle hover lift */
.deck-card {
  border-radius: 1.1rem;
  transition: box-shadow 0.18s, transform 0.18s;
}

.deck-card:hover {
  box-shadow: 0 12px 32px 0 rgba(16, 16, 32, 0.13);
  transform: translateY(-4px) scale(1.01);
}

/* 9. Responsive: bigger touch targets on mobile */
@media (max-width: 640px) {
  .btn {
    font-size: 1rem;
    padding: 1rem 1.1rem;
  }

  .card,
  .dashboard-sidebar,
  .deck-card,
  .flashcard {
    border-radius: 0.8rem;
  }
}

/* 10. Remove any glass/gloss if present */
.card,
.dashboard-sidebar,
.deck-card,
.flashcard {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Utilities */
.hidden {
  display: none !important;
}

.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
}

.level-indicator {
  text-align: center;
  color: #999;
  font-size: 0.8rem;
  margin-top: 1rem;
}

@media (max-width: 640px) {
  .level-indicator.split-mode-indicator {
    margin-top: 4rem;
  }
}

.mobile-only {
  display: none !important;
}

@media (max-width: 768px) {
  .mobile-only {
    display: inline-flex !important;
  }
}

.flex {
  display: flex;
  gap: 1rem;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 0.75rem;
}

.mt-4 {
  margin-top: 1rem;
}

/* Split View Flashcard */
.flashcard-container.split-view {
  background: transparent;
  /* Container is transparent now */
  box-shadow: none;
  /* Remove container shadow */
  display: flex;
  flex-direction: column;
  padding: 0;
  height: auto;
  min-height: auto;
  perspective: none;
  transform-style: flat;
  gap: 1.5rem;
}

.split-content-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  width: 100%;
}

.split-card-face {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  min-height: 300px;
  position: relative;
  transition: transform 0.2s;
  border: 1px solid var(--border);
}

.split-card-face:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.split-card-face .label {
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: rgba(79, 70, 229, 0.1);
  padding: 0.25rem 0.5rem;
  border-radius: 0.3rem;
}

.split-card-face .flashcard-content img {
  height: 180px;
  object-fit: contain;
  border-radius: 0.5rem;
}

.split-controls {
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .split-content-wrapper {
    grid-template-columns: 1fr;
    /* Stack on mobile */
  }

  .split-card-face {
    min-height: 200px;
  }
}

@media (max-width: 640px) {
  .main-header {
    padding: 1rem;
    display: flex;
    gap: 1rem;
  }

  .nav-link {
    margin: 0 0.75rem;
  }

  #main-content {
    padding: 0 0.25rem;
    margin: 0.5rem auto;
  }

  .dashboard-main {
    padding: 1rem 0 !important;
  }

  .card {
    padding: 1rem !important;
  }

  .card-list-item {
    flex-direction: column;
    gap: 0.5rem;
  }

  .card-list-item>div {
    width: 100%;
    grid-template-columns: 1fr;
  }

  .flashcard-container {
    height: 60vh;
    max-height: 500px;
    min-height: 350px;
  }

  .flashcard-face {
    padding: 1rem;
  }

  .flashcard-text {
    font-size: 1.25rem;
  }

  .rating-bar {
    flex-wrap: wrap;
  }

  .rate-btn {
    flex: 1 1 18%;
    padding: 0.75rem 0.25rem;
    font-size: 0.9rem;
  }

  .matching-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.5rem;
  }

  .matching-card {
    min-height: 70px !important;
    font-size: 0.85rem !important;
    padding: 0.5rem !important;
  }

  .quiz-grid {
    grid-template-columns: 1fr !important;
  }

  .quiz-opt {
    padding: 0.75rem !important;
    min-height: auto !important;
  }
}

/* Quiz Grid Desktop Default */
.quiz-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Deck Editor Toolbar */
.deck-editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.toolbar-left,
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.deck-title-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.desktop-inline {
  display: inline;
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .deck-editor-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left {
    justify-content: space-between;
    width: 100%;
  }

  .toolbar-right {
    justify-content: space-between;
    width: 100%;
    margin-top: 0.5rem;
    flex-wrap: wrap;
    /* Allow wrapping if text is long */
  }

  .desktop-inline {
    display: inline;
    /* Show text on mobile */
  }

  .btn-icon-only {
    padding: 0.5rem;
  }
}

/* Matching Game Base */
.matching-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  min-height: 100px;
  padding: 1rem;
}

.quiz-opt {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem;
  border: 1px solid var(--border) !important;
  height: 100%;
  transition: background-color 0.2s, border-color 0.2s;
}

.quiz-opt.matched {
  background-color: #dcfce7 !important;
  color: #166534 !important;
  border-color: #166534 !important;
}

.quiz-opt.mismatch {
  background-color: #fee2e2 !important;
  color: #991b1b !important;
  border-color: #991b1b !important;
  animation: shake 0.5s;
}

body.dark-mode .quiz-opt.matched {
  background-color: #064e3b !important;
  color: #ecfdf5 !important;
  border-color: #ecfdf5 !important;
}

body.dark-mode .quiz-opt.mismatch {
  background-color: #7f1d1d !important;
  color: #fef2f2 !important;
  border-color: #fef2f2 !important;
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }

  25% {
    transform: translateX(-5px);
  }

  50% {
    transform: translateX(5px);
  }

  75% {
    transform: translateX(-5px);
  }

  100% {
    transform: translateX(0);
  }
}

/* Matching Game States */
.matching-card.matched {
  background-color: #dcfce7;
  color: #166534;
}

.matching-card.mismatch {
  background-color: #fee2e2;
  color: #991b1b;
}

body.dark-mode .matching-card.matched {
  background-color: #064e3b;
  color: #ecfdf5;
}

body.dark-mode .matching-card.mismatch {
  background-color: #7f1d1d;
  color: #fef2f2;
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.9);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  cursor: zoom-out;
  opacity: 0;
  animation: fadeIn 0.2s forwards;
}

.lightbox-img {
  max-width: 95%;
  max-height: 95%;
  border-radius: 4px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
  transform: scale(0.9);
  animation: scaleIn 0.2s forwards;
}

.sidebar-toggle {
  display: none;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

body.full-screen #sidebar-toggle {
  display: none !important;
}

@keyframes scaleIn {
  to {
    transform: scale(1);
  }
}

/* Dashboard Layout */
.dashboard-container {
  display: flex !important;
  gap: 2rem;
  align-items: flex-start;
}

.dashboard-sidebar {
  width: 250px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  position: sticky;
  top: 1rem;
}

.dashboard-sidebar .btn,
.dashboard-sidebar .nav-link {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  white-space: normal;
  word-wrap: break-word;
}

/* Sidebar Link - 'Rude Tiger' Style */
.sidebar-link,
.nav-link.sidebar-link {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  position: relative;
  isolation: isolate;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  overflow: hidden;
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  width: 100%;
  white-space: normal !important;
  word-wrap: break-word;
  text-align: left;
  background: transparent;
  /* Default Text Color */
  color: var(--text-muted);
  --gradient: linear-gradient(to bottom, #2eadff, #3d83ff, #7e61ff);
  --color: #32a6ff;
}

/* Inset Background (Before) */
.sidebar-link::before {
  position: absolute;
  content: "";
  inset: 2px;
  border-radius: 0.65rem;
  background: var(--bg-card);
  z-index: 2;
  transition: background 0.3s;
}

/* Dark mode override for inset */
body.dark-mode .sidebar-link::before {
  background: #18181b;
}

/* Left Gradient Bar (After) */
.sidebar-link::after {
  position: absolute;
  content: "";
  width: 4px;
  inset: 10px auto 10px 4px;
  /* Left aligned, slightly inset */
  border-radius: 2px;
  background: var(--gradient);
  transition: transform 300ms ease;
  z-index: 4;
  transform: translateX(-10px);
  /* Hidden by default */
  opacity: 0;
}

/* Hover & Active States */
.sidebar-link:hover::after,
.sidebar-link.active::after {
  transform: translateX(0);
  opacity: 1;
}

.sidebar-link:hover::before,
.sidebar-link.active::before {
  background: rgba(255, 255, 255, 0.5);
  /* Light mode highlight */
}

body.dark-mode .sidebar-link:hover::before,
body.dark-mode .sidebar-link.active::before {
  background: #202025;
  /* Dark mode highlight */
}

/* Content Wrapper (Z-Index fix) */
.sidebar-link-content {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: transform 300ms ease;
  width: 100%;
}

.sidebar-link:hover .sidebar-link-content,
.sidebar-link.active .sidebar-link-content {
  transform: translateX(6px);
  /* Slide text slightly */
  color: var(--primary);
}

body.dark-mode .sidebar-link:hover .sidebar-link-content,
body.dark-mode .sidebar-link.active .sidebar-link-content {
  color: var(--color);
}

/* Glow Effects */
.sidebar-glow,
.sidebar-border-glow {
  position: absolute;
  width: 15rem;
  /* Reduced from 20rem for smaller items */
  height: 15rem;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle closest-side at center, rgba(255, 255, 255, 0.4), transparent);
  opacity: 0;
  transition: opacity 300ms ease;
  pointer-events: none;
  top: 50%;
  /* Center initially */
  left: 50%;
}

.sidebar-glow {
  z-index: 3;
}

.sidebar-border-glow {
  z-index: 1;
  background: radial-gradient(circle closest-side at center, var(--primary), transparent);
}

.sidebar-link:hover .sidebar-glow {
  opacity: 0.1;
}

.sidebar-link:hover .sidebar-border-glow {
  opacity: 0.15;
}

.sidebar-link.active .sidebar-glow {
  opacity: 0.05;
}


.dashboard-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1rem;
}

.dashboard-main>* {
  width: 100%;
}

@media (min-width: 769px) {
  #main-content {
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .dashboard-container {
    display: grid !important;
    grid-template-columns: 260px 1fr;
    gap: 2rem;
    padding: 1.5rem;
  }

  .dashboard-sidebar {
    width: 100%;
    height: calc(100vh - 9rem);
    /* Full height minus header (approx 5rem) and margins (4rem) */
    max-height: none;
    position: sticky;
    top: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    transition: all .5s ease;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow-y: auto;
    z-index: 10;
  }

  .dashboard-main {
    position: relative;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    max-width: 1200px;
    padding: 0;
  }
}

@media (max-width: 768px) {
  .dashboard-container {
    flex-direction: column;
    align-items: stretch !important;
  }

  .dashboard-sidebar {
    display: none;
    position: relative;
    margin-left: auto;
    margin-right: auto;
    height: 100%;
    z-index: 100;
    background: var(--bg-card);
    width: 100%;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
    transition: all .5s ease;
    transform: translateY(0);
    top: 0.1rem;
  }

  .dashboard-container.sidebar-open .dashboard-sidebar {
    display: flex;
    transform: translateY(0);
  }

  .sidebar-toggle {
    display: block;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 1.6rem;
    cursor: pointer;
    right: 10%;
    position: absolute;
  }
}

body.dark-mode .quiz-opt {
  background: var(--bg-card) !important;
  color: var(--text-main);
}

/* Mobile Responsiveness Improvements */
@media (hover: none) {

  /* Disable hover effects on touch devices to prevent sticky states */
  .sidebar-link:hover::after,
  .sidebar-link:hover::before {
    /* Reset to non-hover state unless active */
    transform: translateX(-10px);
    opacity: 0;
  }

  .sidebar-link:hover .sidebar-link-content {
    transform: none;
    color: var(--text-muted);
  }

  .sidebar-link:hover::before {
    background: transparent;
  }

  /* Keep Active State Strong */
  .sidebar-link.active::after {
    transform: translateX(0) !important;
    opacity: 1 !important;
  }

  .sidebar-link.active::before {
    background: rgba(255, 255, 255, 0.5) !important;
  }

  body.dark-mode .sidebar-link.active::before {
    background: #202025 !important;
  }

  .sidebar-link.active .sidebar-link-content {
    transform: translateX(6px) !important;
    color: var(--primary) !important;
  }

  body.dark-mode .sidebar-link.active .sidebar-link-content {
    color: var(--color) !important;
  }
}

@media (max-width: 768px) {

  /* Ensure Sidebar is top-most on mobile */
  .dashboard-sidebar {
    z-index: 9999 !important;
    /* Force high z-index */
  }

  /* Bigger touch targets */
  .sidebar-link {
    padding: 1rem !important;
    /* 16px vertical padding for easier tapping */
  }
}

/* Cookie Banner */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background: var(--bg-card);
  /* Fixed: Was undefined --surface */
  border-top: 1px solid var(--border);
  padding: 1rem;
  /* Reduced padding for mobile */
  z-index: 10000;
  box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1);
  transform: translateY(100%);
  transition: transform 0.3s ease-in-out;
}

.cookie-banner.visible {
  transform: translateY(0);
}

.cookie-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
}

.cookie-text {
  flex: 1;
  min-width: 200px;
  /* Reduced to fit smaller screens */
  color: var(--text-muted);
  /* Used defined var */
  font-size: 0.85rem;
  /* Slightly smaller text */
}

.cookie-buttons {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  /* Full width on very small screens if wrapped */
}

@media (min-width: 640px) {
  .cookie-buttons {
    width: auto;
  }
}

/* Footer */
.main-footer {
  padding: 2rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.9rem;
  border-top: 1px solid var(--border);
  background: var(--background);
}

.main-footer a {
  color: var(--primary);
  text-decoration: none;
}

.main-footer a:hover {
  text-decoration: underline;
}

/* Toast Notification */
#toast-notification {
  visibility: hidden;
  min-width: 250px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 8px;
  padding: 16px;
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  font-size: 1rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transition: opacity 0.3s, bottom 0.3s;
}

#toast-notification.show {
  visibility: visible;
  opacity: 1;
  bottom: 50px;
}