:root {
  --accent: #6366f1;
  --accent2: #818cf8;
  --accent-rgb: 99, 102, 241;
  --accent2-rgb: 129, 140, 248;
  --bg-body: #0a0a12;
  --text-body: #e2e8f0;
  --bg-card: rgba(255, 255, 255, 0.05);
  --bg-card-solid: #1a1a2e;
  --bg-elevated: rgba(255, 255, 255, 0.06);
  --bg-hover: rgba(255, 255, 255, 0.08);
  --bg-input: rgba(255, 255, 255, 0.06);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-input: rgba(255, 255, 255, 0.08);
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --shadow-card: none;
}


html.light {
  /* Slightly warmer off-white — softer on eyes than pure #fff */
  --bg-body: #eef2f7;
  --text-body: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  /* Solid cards — no translucent blur on light bg (avoids muddiness) */
  --bg-card: #ffffff;
  --bg-card-solid: #ffffff;
  --bg-elevated: #f8fafc;
  --bg-hover: #f1f5f9;
  --bg-input: #f8fafc;

  /* Stronger borders for legibility */
  --border-card: rgba(15, 23, 42, 0.08);
  --border-input: rgba(15, 23, 42, 0.12);

  /* Multi-layer elevation shadow — this is the key to "lift" cards off the bg */
  --shadow-card:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 4px 12px rgba(15, 23, 42, 0.05),
    0 0 0 1px rgba(15, 23, 42, 0.03);
}

* {
  box-sizing: border-box;
}

html, body {
  background: var(--bg-body);
  color: var(--text-body);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
  line-height: 1.6;
}

body {
  padding: 1rem;
}

/* Button hover effects */
.btn-hover {
  transition: transform 0.1s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.btn-hover:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
.btn-hover:active {
  transform: translateY(0) scale(0.98);
}

.glass-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  backdrop-filter: blur(12px);
  border-radius: 1.5rem;
  padding: 1.25rem;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
  box-shadow: var(--shadow-card);
}

@media (min-width: 640px) {
  .glass-card {
    padding: 1.5rem;
  }
}

input:not([type="color"]):not([type="range"]),
textarea,
select {
  width: 100%;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 0.75rem;
  color: var(--text-body);
  font-size: 0.9rem;
  transition: border-color 0.2s, background 0.2s, color 0.2s;
}

/* Color picker: compact swatch, not full width */
input[type="color"] {
  width: 3rem !important;
  height: 2rem !important;
  min-width: 3rem;
  padding: 0.15rem;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}
input[type="color"]:hover {
  border-color: var(--accent);
}
input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}
input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 0.35rem;
}
input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 0.35rem;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

.btn-primary {
  padding: 0.7rem 1.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 0.75rem;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s, opacity 0.2s, box-shadow 0.2s;
}
.btn-primary:hover {
  background: var(--accent2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.tab-active {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent2);
}
html.light .tab-active {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}
.tab-inactive {
  color: #94a3b8;
}
html.light .tab-inactive {
  color: #475569;
}
.tab-inactive:hover {
  background: var(--bg-hover);
}

.reveal-item {
  animation: reveal 0.35s ease-out forwards;
  opacity: 0;
  transform: translateY(8px);
}
@keyframes reveal {
  to { opacity: 1; transform: translateY(0); }
}

.quiz-option {
  cursor: pointer;
  min-height: 44px;
  overflow-wrap: anywhere;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#viewTest fieldset {
  min-width: 0;
}
#viewTest .test-type-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  padding-bottom: 0.25rem;
  width: 100%;
  min-width: 0;
}
.test-type-picker label,
.test-inline-btn,
.test-secondary-btn {
  min-height: 44px;
}
.test-type-picker label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border-card);
  border-radius: 0.65rem;
  background: rgba(255,255,255,0.05);
  font-size: 0.75rem;
  white-space: normal;
  overflow-wrap: anywhere;
}
.test-inline-btn,
.test-secondary-btn {
  padding: 0.65rem 0.9rem;
  border: 1px solid var(--border-card);
  border-radius: 0.65rem;
  background: rgba(255,255,255,0.08);
  font-size: 0.8rem;
}
.test-secondary-btn { width: 100%; }
.test-paused { opacity: 0.65; }
.test-history-panel {
  padding: 0.9rem;
  border: 1px solid var(--border-card);
  border-radius: 0.75rem;
  background: rgba(255,255,255,0.04);
}
.test-history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.75rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--border-card);
  font-size: 0.75rem;
}
.test-history-row span:last-child { grid-column: 1 / -1; opacity: 0.6; }
:is(.test-inline-btn, .test-secondary-btn, #testOptionsContainer button, #testOptionsContainer select):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
@media (min-width: 640px) {
  #viewTest .test-type-picker {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
.quiz-option:hover {
  background: rgba(99, 102, 241, 0.08);
}
html.light .quiz-option:hover {
  background: rgba(99, 102, 241, 0.1);
}

.saved-card {
  transition: background 0.15s, border-color 0.15s;
  position: relative;
  -webkit-touch-callout: none;
  user-select: none;
}
.saved-card:hover {
  background: var(--bg-hover);
  border-color: rgba(255, 255, 255, 0.2);
}


html.light .saved-card:hover {
  border-color: rgba(0, 0, 0, 0.15);
}

#gcashFull p {
  word-break: break-all;
}

/* ============ LIGHT MODE OVERRIDES FOR TAILWIND UTILITIES ============ */
html.light .bg-white\/5 {
  background: rgba(0, 0, 0, 0.04) !important;
}
html.light .bg-white\/10 {
  background: rgba(0, 0, 0, 0.06) !important;
}
html.light .bg-white\/20 {
  background: rgba(0, 0, 0, 0.08) !important;
}
html.light .border-white\/10 {
  border-color: rgba(0, 0, 0, 0.08) !important;
}
html.light .border-white\/5 {
  border-color: rgba(0, 0, 0, 0.05) !important;
}
html.light .border-white\/20 {
  border-color: rgba(0, 0, 0, 0.12) !important;
}
html.light .text-gray-400 {
  color: #475569 !important;
}
html.light .text-white {
  color: #0f172a !important;
}
html.light .text-white.bg-indigo-600,
html.light .text-white.bg-rose-500,
html.light .text-white.bg-emerald-600,
html.light .text-white.btn-primary {
  color: #ffffff !important;
}
html.light .opacity-50 {
  opacity: 0.6;
}
html.light .opacity-70 {
  opacity: 0.75;
}
html.light .font-mono {
  color: #1e293b;
}
html.light .hover\:border-indigo-400\/50:hover {
  border-color: rgba(99, 102, 241, 0.5) !important;
}
html.light .accent-indigo-500 {
  accent-color: #6366f1;
}
html.light .animate-spin {
  color: #6366f1;
}

/* Specific component overrides */
html.light #wakeUpOverlay {
  background: #f1f5f9 !important;
  color: #0f172a !important;
}
html.light #wakeUpOverlay h1 {
  color: #0f172a;
}
html.light #wakeUpOverlay p {
  color: #334155;
}
html.light footer {
  color: #64748b !important;
}
html.light footer a {
  color: #6366f1 !important;
}
html.light .bg-emerald-500\/10 {
  background: rgba(16, 185, 129, 0.1) !important;
}
html.light .border-emerald-500\/20 {
  border-color: rgba(16, 185, 129, 0.25) !important;
}
html.light .text-emerald-400 {
  color: #059669 !important;
}
html.light .bg-emerald-500\/20 {
  background: rgba(16, 185, 129, 0.18) !important;
}
html.light .border-emerald-500 {
  border-color: #10b981 !important;
}
html.light .text-emerald-300 {
  color: #047857 !important;
}

html.light .border-rose-500 {
  border-color: #ef4444 !important;
}
html.light .text-rose-300 {
  color: #b91c1c !important;
}
html.light .text-rose-400 {
  color: #dc2626 !important;
}
html.light .bg-amber-500\/20 {
  background: rgba(245, 158, 11, 0.15) !important;
}
html.light .text-amber-400 {
  color: #d97706 !important;
}
html.light .text-amber-300 {
  color: #b45309 !important;
}

html.light .text-cyan-400 {
  color: #0891b2 !important;
}
html.light .text-teal-400 {
  color: #0d9488 !important;
}
html.light .text-blue-400 {
  color: #2563eb !important;
}
html.light .bg-rose-500\/20 {
  background: rgba(239, 68, 68, 0.12) !important;
}
html.light .hover\:bg-rose-500\/30:hover {
  background: rgba(239, 68, 68, 0.2) !important;
}
html.light .bg-rose-500\/10 {
  background: rgba(239, 68, 68, 0.08) !important;
}
html.light .bg-black\/60 {
  background: rgba(0, 0, 0, 0.4) !important;
}
html.light .bg-gradient-to-r.from-indigo-400.to-cyan-300 {
  background: linear-gradient(to right, #6366f1, #0891b2) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
}
html.light #starContainer .fa-star {
  color: #94a3b8;
}
html.light #starContainer .fa-star.text-amber-400,
html.light #starContainer .fa-star.fa-solid {
  color: #f59e0b !important;
}
html.light #starContainer .fa-star:hover {
  color: #f59e0b !important;
}
html.light select option {
  background: #ffffff;
  color: #0f172a;
}
html.light label {
  color: var(--text-body);
}

/* Overdue */
.overdue {
  border-left: 3px solid #ef4444 !important;
}

/* Drag over effect */
.drag-over {
  background: rgba(99, 102, 241, 0.15) !important;
  border-color: #6366f1 !important;
}

/* Tooltip */
[data-tooltip] {
  position: relative;
}
[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a2e;
  color: #e2e8f0;
  padding: 0.4rem 0.6rem;
  border-radius: 0.5rem;
  font-size: 0.7rem;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  border: 1px solid rgba(255,255,255,0.1);
}
html.light [data-tooltip]:hover::after {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(0,0,0,0.1);
}

#wakeUpOverlay {
  z-index: 2000;
}

/* Test question card */
html.light #testQuestionCard {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

/* Summary list items */
html.light #summaryList li {
  background: rgba(0, 0, 0, 0.03) !important;
}

/* Flashcard grid items */
html.light #flashcardGrid > div {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

/* Quiz container items */
html.light #quizContainer > div {
  background: rgba(0, 0, 0, 0.03) !important;
  border-color: rgba(0, 0, 0, 0.08) !important;
}

/* Profile modal input overrides */
html.light #evalModal textarea {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
}
html.light #gcashHidden p,
html.light #gcashFull p {
  color: #0f172a !important;
}
html.light #testResultsContainer h3 {
  color: #0f172a;
}
html.light #testResultsContainer .text-2xl {
  color: #0f172a;
}

/* Flashcard flip */
.flashcard {
  perspective: 1000px;
  cursor: pointer;
  height: 10rem; /* fixed height */
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s;
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}
.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--bg-card-solid);
  border: 1px solid var(--border-card);
}
.flashcard-back {
  transform: rotateY(180deg);
}
/* Review mode */
.review-item {
  border-left: 3px solid transparent;
  padding: 0.75rem;
  border-radius: 0.5rem;
  background: rgba(255,255,255,0.03);
  margin-bottom: 0.5rem;
}
.review-item.correct {
  border-left-color: #10b981;
  background: rgba(16,185,129,0.05);
}
.review-item.incorrect {
  border-left-color: #ef4444;
  background: rgba(239,68,68,0.05);
}
/* Settings modal */
#settingsModal .glass-card {
  padding: 1.5rem;
}

/* ============ TAB BAR — permanently fixed at bottom ============ */
#mainWrapper {
  padding-bottom: calc(6.5rem + env(safe-area-inset-bottom));
}

#tabContainer {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(48rem, calc(100vw - 2rem));
  z-index: 45;
  margin: 0;
  border-radius: 1rem 1rem 0 0;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-bottom: none;
  padding: 0.5rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  flex-wrap: nowrap;
}

html.light #tabContainer {
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.06);
}

#tabContainer button {
  flex: 1 1 0;
  min-width: 0;
  padding: 0.6rem 0.35rem;
  font-size: 0.7rem;
}

/* Keep tabs below content in the flex flow */
#tabContainer  { order: 4; }
#viewsContainer { order: 3; }

/* Calendar styles */
#calendarGrid {
  grid-template-columns: repeat(7, 1fr);
}
.calendar-day-header {
  font-weight: 600;
  font-size: 0.75rem;
  padding: 0.5rem 0;
  color: var(--text-secondary);
}
.calendar-day {
  min-height: 60px;
  padding: 0.4rem;
  border-radius: 0.5rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  position: relative;
}
.calendar-day:hover {
  background: var(--bg-hover);
  border-color: var(--accent);
}
.calendar-day.empty {
  background: transparent;
  border-color: transparent;
  cursor: default;
}
.calendar-day.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.calendar-day.selected {
  background: rgba(99,102,241,0.2);
  border-color: #6366f1;
}
.calendar-day .task-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  margin-top: 4px;
  display: inline-block;
}
.calendar-day .task-dot.multiple {
  background: #f59e0b;
}
.calendar-day .task-count {
  font-size: 0.6rem;
  opacity: 0.8;
  margin-top: 2px;
}
html.light .calendar-day {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.05);
}
html.light .calendar-day:hover {
  background: rgba(0,0,0,0.06);
}
html.light .calendar-day.selected {
  background: rgba(99,102,241,0.15);
}

/* ============ WAKE-UP OVERLAY SPINNER FIX ============ */

/* Ensure spinner is visible */
#wakeUpOverlay .fa-spinner,
#wakeUpOverlay .animate-spin,
.fa-spinner.animate-spin {
  display: inline-block !important;
  animation: spin 1s linear infinite !important;
  color: #6366f1 !important;
  font-size: 1.2rem !important;
}

/* Define spin animation if Tailwind doesn't load */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Wake-up overlay loading states */
#wakeUpOverlay .loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

/* Status text styles */
#wakeUpStatus {
  transition: color 0.3s ease;
  min-height: 24px;
}

#wakeUpStatus.loading {
  color: #94a3b8;
}

#wakeUpStatus.success {
  color: #10b981;
}

#wakeUpStatus.error {
  color: #f59e0b;
}

/* Button loading state */
#retryWakeBtn.loading {
  opacity: 0.7;
  cursor: wait;
}

/* Fade out animation for overlay */
#wakeUpOverlay.fade-out {
  opacity: 0;
  transition: opacity 0.5s ease;
}

/* Light mode spinner */
html.light #wakeUpOverlay .fa-spinner,
html.light #wakeUpOverlay .animate-spin {
  color: #6366f1 !important;
}

/* ============ TAB BUTTON CLICK FIX ============ */

/* Ensure tab container and buttons are above other elements */
/* Tab container — must sit BELOW modals (which start at z-50) */
#tabContainer {
  z-index: 45;
}

#tabContainer button {
  pointer-events: auto !important;
  cursor: pointer !important;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

/* Ensure no other elements overlap the tabs */
#mainWrapper > *:not(#tabContainer) {
  position: relative;
}

#mainWrapper .glass-card.header {
  z-index: 50;
}

#viewsContainer {
  z-index: auto;
}

/* Make sure tab buttons are always clickable even on mobile */




/* Add visual feedback for tab clicks */
#tabContainer button:active {
  transform: scale(0.97);
}

/* Fix for potential iOS Safari issues */
@supports (-webkit-touch-callout: none) {
  #tabContainer button {
    cursor: pointer;
    touch-action: manipulation;
  }
}



/* ============ ACTION SHEETS (bottom sheet menus) ============ */
.subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 600;
  margin-top: 0.35rem;
}

.card-menu-btn {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  transition: background 0.15s;
}
.card-menu-btn:hover {
  background: rgba(255, 255, 255, 0.16);
}
html.light .card-menu-btn {
  background: rgba(0, 0, 0, 0.06);
}
html.light .card-menu-btn:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* ============ iOS MODAL/SHEET ANIMATION HELPERS ============ */

[data-modal] {
  transition: opacity 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}

[data-modal].is-closing {
  pointer-events: none;
}

[data-modal].hidden {
  display: none !important;
}

[data-modal] * {
  will-change: transform, opacity;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  [data-modal] * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============ SHARE FEATURE ============ */



#shareLinkInput {
  font-family: 'Inter', system-ui, monospace;
  cursor: text;
  user-select: all;
  -webkit-user-select: all;
}

html.light #shareLinkInput {
  background: rgba(0, 0, 0, 0.04) !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0f172a !important;
}

/* ============ RESULTS NAV (sticky section navigation) ============ */

#sectionSummary,
#sectionFlashcards,
#sectionQuiz {
  scroll-margin-top: 5rem;
}

#resultsNav {
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.results-nav-btn {
  display: inline-flex;
  flex-direction: column;   /* ← stack top row + label */
  align-items: center;
  justify-content: center;
  gap: 0.2rem;              /* ← tighter gap between the two rows */
  padding: 0.5rem 0.6rem;
  border-radius: 0.75rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  -webkit-tap-highlight-color: transparent;
}

/* Icon + count row */
.results-nav-top {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

/* Label below the row */
.results-nav-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  opacity: 0.9;
}

.results-nav-btn:hover {
  background: var(--bg-hover);
  color: var(--text-body);
}

.results-nav-btn.active {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}

html.light .results-nav-btn.active {
  background: rgba(99, 102, 241, 0.12);
  color: #4338ca;
}

.results-nav-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.1);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}

html.light .results-nav-count {
  background: rgba(0, 0, 0, 0.08);
}

.results-nav-btn.active .results-nav-count {
  background: rgba(99, 102, 241, 0.35);
  color: #fff;
}

html.light .results-nav-btn.active .results-nav-count {
  background: rgba(99, 102, 241, 0.25);
  color: #4338ca;
}

/* ============ NOTES FEATURE ============ */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card {
  transition: background 0.15s, border-color 0.15s;
  cursor: pointer;
  min-height: 8.5rem;
}
.note-card:hover {
  background: var(--bg-hover);
  border-color: rgba(255,255,255,0.2);
}
.note-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.notes-count {
  color: var(--text-muted);
  font-size: 0.65rem;
  font-weight: 500;
  white-space: nowrap;
}
.notes-filter-empty {
  grid-column: 1 / -1;
  padding: 1.5rem 0;
  text-align: center;
}
html.light .note-card:hover {
  border-color: rgba(0,0,0,0.15);
}

.subject-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  color: var(--text-secondary);
}
.subject-filter-pill:hover {
  background: var(--bg-hover);
  color: var(--text-body);
}
.subject-filter-pill.active {
  background: rgba(99,102,241,0.15);
  border-color: rgba(99,102,241,0.35);
  color: #a5b4fc;
}
html.light .subject-filter-pill.active {
  color: #4338ca;
}

.note-subject-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.1rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 600;
}
.note-subject-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  display: inline-block;
  flex-shrink: 0;
}

#notePinBtn.active {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}
html.light #notePinBtn.active {
  color: #d97706;
}

#noteBodyInput {
  font-family: 'Inter', system-ui, sans-serif;
  line-height: 1.65;
}

.note-format-toolbar {
  display: flex;
  gap: 0.25rem;
}
.note-format-toolbar button {
  width: 1.8rem;
  height: 1.8rem;
  border: 1px solid var(--border-input);
  border-radius: 0.45rem;
  color: var(--text-secondary);
  background: var(--bg-input);
  cursor: pointer;
  line-height: 1;
  touch-action: manipulation;
}
.note-format-toolbar button:hover,
.note-format-toolbar button:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  outline: none;
}
.note-editor {
  min-height: 40vh;
  padding: 0.7rem 1rem;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 0.75rem;
  overflow-y: auto;
  white-space: pre-wrap;
}
.note-editor:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-elevated);
}
.note-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

#noteSearchInput::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ============ FLASHCARD STUDY MODE ============ */
#studyModeOverlay,
#studyCompleteOverlay {
  animation: reveal 0.2s ease-out;
}

#studyCard {
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#studyCard:active {
  transform: scale(0.995);
}

#studyCard.swipe-left {
  animation: studySlideLeft 0.25s ease-out;
}
#studyCard.swipe-right {
  animation: studySlideRight 0.25s ease-out;
}

@keyframes studySlideLeft {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-30px); opacity: 0; }
}
@keyframes studySlideRight {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(30px); opacity: 0; }
}

#studyShuffleBtn.active {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}

/* Badge on browse cards after rating */
.flashcard .study-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  border-radius: 0.5rem;
  line-height: 1;
}
.flashcard .study-badge.easy { color: #34d399; background: rgba(16,185,129,0.15); }
.flashcard .study-badge.hard { color: #fbbf24; background: rgba(245,158,11,0.15); }
.flashcard .study-badge.forgot { color: #f87171; background: rgba(239,68,68,0.15); }

.flashcard { position: relative; }

/* Light mode overrides */
html.light #studyModeOverlay,
html.light #studyCompleteOverlay {
  background: rgba(0,0,0,0.5);
}
html.light #studyCard {
  background: rgba(0,0,0,0.03);
  border-color: rgba(0,0,0,0.08);
}

/* ============ SPLASH / LOADING SCREEN ============ */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0a0a12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.splash-screen.splash-hide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Animated glows behind the logo */
.splash-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  pointer-events: none;
}
.splash-glow-1 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #6366f1 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: splashPulse 3s ease-in-out infinite;
}
.splash-glow-2 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, #06b6d4 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: splashPulse 3s ease-in-out infinite 1.2s;
  opacity: 0.35;
}

@keyframes splashPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.4; }
  50%      { transform: translate(-50%, -50%) scale(1.15); opacity: 0.65; }
}

/* Content wrapper */
.splash-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0 1.5rem;
}

/* Logo — circular badge with orbiting rings */
.splash-logo {
  position: relative;
  width: 112px;
  height: 112px;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: splashLogoIn 0.9s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.splash-logo-inner {
  width: 88px;
  height: 88px;
  border-radius: 24px;
  background: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 2.25rem;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 8px 32px rgba(99, 102, 241, 0.45),
    0 0 60px rgba(6, 182, 212, 0.25);
  z-index: 2;
  animation: splashLogoGlow 2.4s ease-in-out infinite;
}

.splash-logo-inner i {
  animation: splashCapTilt 3s ease-in-out infinite;
  transform-origin: center 70%;
}

/* Orbiting rings */
.splash-logo-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: rgba(99, 102, 241, 0.85);
  border-right-color: rgba(99, 102, 241, 0.25);
  animation: splashSpin 1.4s linear infinite;
}
.splash-logo-ring-2 {
  inset: -14px;
  border-top-color: rgba(6, 182, 212, 0.7);
  border-right-color: transparent;
  border-bottom-color: rgba(6, 182, 212, 0.2);
  animation: splashSpin 2.2s linear infinite reverse;
}

@keyframes splashLogoIn {
  0%   { transform: scale(0.3) translateY(20px); opacity: 0; }
  60%  { transform: scale(1.08) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes splashLogoGlow {
  0%, 100% { box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset, 0 8px 32px rgba(99,102,241,0.45), 0 0 60px rgba(6,182,212,0.25); }
  50%      { box-shadow: 0 0 0 1px rgba(255,255,255,0.08) inset, 0 8px 42px rgba(99,102,241,0.65), 0 0 90px rgba(6,182,212,0.45); }
}
@keyframes splashCapTilt {
  0%, 100% { transform: rotate(-6deg); }
  50%      { transform: rotate(6deg); }
}
@keyframes splashSpin {
  to { transform: rotate(360deg); }
}

/* Title — letters fade up with stagger */
.splash-title {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.5rem;
  background: linear-gradient(
    90deg,
    #a5b4fc 0%,
    #67e8f9 40%,
    #ffffff 50%,
    #67e8f9 60%,
    #a5b4fc 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: flex;
  gap: 0;
  white-space: nowrap; /* NEW: Prevents wrapping on small screens */
  animation: splashTitleShine 2.5s ease-in-out 1.2s infinite;
}

@keyframes splashTitleShine {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

.splash-title span {
  display: inline-block;
  opacity: 0;
  transform: translateY(14px);
  animation: splashLetterIn 0.5s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
}

/* Existing delays */
.splash-title span:nth-child(1) { animation-delay: 0.30s; } /* A */
.splash-title span:nth-child(2) { animation-delay: 0.38s; } /* c */
.splash-title span:nth-child(3) { animation-delay: 0.46s; } /* a */
.splash-title span:nth-child(4) { animation-delay: 0.54s; } /* d */
.splash-title span:nth-child(5) { animation-delay: 0.62s; } /* H */
.splash-title span:nth-child(6) { animation-delay: 0.70s; } /* u */
.splash-title span:nth-child(7) { animation-delay: 0.78s; } /* b */

/* NEW delays for " Suite" */
.splash-title span:nth-child(8)  { animation-delay: 0.86s; } /* (space) */
.splash-title span:nth-child(9)  { animation-delay: 0.94s; } /* S */
.splash-title span:nth-child(10) { animation-delay: 1.02s; } /* u */
.splash-title span:nth-child(11) { animation-delay: 1.10s; } /* i */
.splash-title span:nth-child(12) { animation-delay: 1.18s; } /* t */
.splash-title span:nth-child(13) { animation-delay: 1.26s; } /* e */

@keyframes splashLetterIn {
  to { opacity: 1; transform: translateY(0); }
}

/* Tagline */
.splash-tagline {
  font-size: 0.85rem;
  color: #94a3b8;
  margin: 0 0 2rem;
  opacity: 0;
  animation: splashFadeUp 0.6s ease 0.95s forwards;
}

@keyframes splashFadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Footer text */
.splash-footer {
  position: absolute;
  bottom: 4rem;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 0.72rem;
  color: #475569;
  letter-spacing: 0.05em;
  opacity: 0;
  animation: splashFadeUp 0.6s ease 1.3s forwards;
}

/* Light mode */
html.light .splash-screen {
  background: #f1f5f9;
}
html.light .splash-logo-inner {
  box-shadow:
    0 0 0 1px rgba(0,0,0,0.04) inset,
    0 8px 32px rgba(99, 102, 241, 0.35),
    0 0 60px rgba(6, 182, 212, 0.2);
}
html.light .splash-tagline { color: #475569; }
html.light .splash-footer  { color: #94a3b8; }

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .splash-glow,
  .splash-logo,
  .splash-logo-inner,
  .splash-logo-inner i,
  .splash-logo-ring,
  .splash-title span,
  .splash-tagline,
  .splash-footer {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
/* ============ BACKEND STATUS DOT ============ */
.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  background: #94a3b8;
  transition: background 0.3s ease, box-shadow 0.3s ease;
  cursor: help;
  flex-shrink: 0;
}
.status-dot.checking {
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
  animation: statusPulse 1.4s ease-in-out infinite;
}
.status-dot.online {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
  animation: none;
}
.status-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.2);
  animation: none;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.4; }
}
html.light .status-dot.online  { box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.25); }
html.light .status-dot.offline { box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.25); }

/* ============ SPLASH PROGRESS BAR ============ */
.splash-progress {
  width: 240px; /* Slightly wider for better visual balance */
  margin-top: 1.5rem;
  text-align: center;
  opacity: 0;
  animation: splashFadeUp 0.5s ease 1.3s forwards;
}

.splash-progress-bar {
  height: 6px; /* Upgraded from 3px to 6px */
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden; /* Crucial for the shimmer effect */
  position: relative;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.splash-progress-fill {
  height: 100%;
  width: 0%;
  /* Your existing gradient is perfect */
  background: linear-gradient(90deg, #6366f1 0%, #818cf8 50%, #06b6d4 100%);
  border-radius: 9999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  /* Upgraded: Pulsing glow effect */
  animation: splashPulseGlow 2s infinite alternate;
}

/* Upgraded: Animated shimmer/sheen */
.splash-progress-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg, 
    rgba(255,255,255,0) 0%, 
    rgba(255,255,255,0.4) 50%, 
    rgba(255,255,255,0) 100%
  );
  animation: splashShimmer 1.5s infinite;
}

.splash-progress-text {
  font-size: 0.75rem;
  color: #64748b;
  margin-top: 0.6rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

/* Upgraded: New Keyframe Animations */
@keyframes splashPulseGlow {
  0% { 
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.3); 
  }
  100% { 
    box-shadow: 0 0 16px rgba(6, 182, 212, 0.6), 
                0 0 24px rgba(99, 102, 241, 0.4); 
  }
}

@keyframes splashShimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

/* Light mode */
html.light .splash-progress-bar {
  background: rgba(0, 0, 0, 0.06);
}
html.light .splash-progress-fill {
  /* Soften the glow for light mode so it doesn't look blurry */
  animation: splashPulseGlowLight 2s infinite alternate;
}
html.light .splash-progress-text {
  color: #94a3b8;
}

@keyframes splashPulseGlowLight {
  0% { box-shadow: 0 0 6px rgba(99, 102, 241, 0.2); }
  100% { box-shadow: 0 0 12px rgba(6, 182, 212, 0.4); }
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .splash-progress-bar {
    height: 8px; /* Slightly thicker on mobile for visibility */
  }
}
/* ============ SPLASH FOOTER TIP CAROUSEL ============ */
#splashFooterText {
  display: inline-block;
  transition: opacity 0.4s ease, transform 0.4s ease;
  will-change: opacity, transform;
}

#splashFooterText.fade-out {
  opacity: 0;
  transform: translateY(4px);
}

#splashFooterText.fade-in {
  opacity: 1;
  transform: translateY(0);
}

/* Ensure it respects reduced motion */
@media (prefers-reduced-motion: reduce) {
  #splashFooterText {
    transition: none !important;
  }
}

/* ============ FLOATING ACADEMIC PARTICLES ============ */
.splash-particles {
  position: absolute;
  inset: 0;
  pointer-events: none; /* Ensures particles don't block clicks */
  overflow: hidden;
  z-index: 1; /* Sits behind the main content */
}

.particle {
  position: absolute;
  color: #6366f1;
  opacity: 0.08; /* Very subtle, won't distract */
  animation: floatParticle 15s infinite ease-in-out alternate;
  will-change: transform;
}

/* Individual positions, sizes, and animation variations */
.p1 { top: 15%; left: 15%; font-size: 2rem;   animation-duration: 12s; }
.p2 { top: 25%; right: 15%; font-size: 2.5rem; animation-duration: 18s; animation-delay: -2s; color: #06b6d4; }
.p3 { bottom: 30%; left: 10%; font-size: 1.8rem; animation-duration: 14s; animation-delay: -4s; color: #818cf8; }
.p4 { bottom: 15%; right: 20%; font-size: 2.2rem; animation-duration: 16s; animation-delay: -6s; color: #a5b4fc; }
.p5 { top: 10%; left: 45%; font-size: 1.5rem; animation-duration: 20s; animation-delay: -8s; color: #67e8f9; }
.p6 { bottom: 20%; left: 45%; font-size: 2rem;   animation-duration: 15s; animation-delay: -10s; }
.p7 { top: 40%; left: 5%;  font-size: 1.7rem; animation-duration: 22s; animation-delay: -3s; color: #06b6d4; }
.p8 { top: 45%; right: 8%; font-size: 1.9rem; animation-duration: 17s; animation-delay: -7s; color: #818cf8; }

/* Smooth, organic floating motion */
@keyframes floatParticle {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }
  50% {
    transform: translate(15px, -25px) rotate(15deg);
  }
  100% {
    transform: translate(-10px, -50px) rotate(-10deg);
  }
}

/* Light mode adjustments */
html.light .particle {
  opacity: 0.12;
  color: #4338ca;
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
  .particle {
    animation: none !important;
    opacity: 0.05 !important;
  }
}

/* ============ SAVED-ITEM VIEWER MODE ============ */
/* Triggered by ?view=<id> — opened from Library in a new window.
   Hides app chrome, leaving only the reviewer. */

body.viewer-mode { padding: 0.5rem; }

/* Hide header, tab bar, donation card */
body.viewer-mode #mainWrapper > .glass-card.header,
body.viewer-mode #tabContainer,
body.viewer-mode #mainWrapper > .glass-card.mt-6 {
  display: none !important;
}

/* Hide every view except the reviewer */
body.viewer-mode #viewNotes,
body.viewer-mode #viewLibrary,
body.viewer-mode #viewTest,
body.viewer-mode #viewCalendar {
  display: none !important;
}

/* Hide the "Generate Study Materials" form card — results stay */
body.viewer-mode #viewReviewer > .glass-card {
  display: none !important;
}

/* Hide the shared-reviewer banner (that's for shared, not saved items) */
body.viewer-mode #sharedBanner {
  display: none !important;
}

/* Already saved — hide that button */
body.viewer-mode #saveToLibraryBtn {
  display: none !important;
}

body.viewer-mode > footer {
  display: none !important;
}

#viewReviewer.saved-view-mode > .glass-card {
  display: none !important;
}
/* ============ SKELETON LOADERS ============ */
.skeleton-block {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.09) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.4s ease-in-out infinite;
  border-radius: 0.5rem;
  display: block;
}
html.light .skeleton-block {
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.04) 0%,
    rgba(0, 0, 0, 0.08) 50%,
    rgba(0, 0, 0, 0.04) 100%
  );
  background-size: 200% 100%;
}

@keyframes skeletonShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-line {
  height: 0.75rem;
  margin-bottom: 0.5rem;
}
.skeleton-line.w-90 { width: 90%; }
.skeleton-line.w-75 { width: 75%; }
.skeleton-line.w-60 { width: 60%; }
.skeleton-line.w-40 { width: 40%; }

.skeleton-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 1rem;
  padding: 1rem;
}

.skeleton-flashcard {
  height: 10rem;
  border-radius: 0.75rem;
}

.skeleton-title {
  height: 1rem;
  width: 55%;
  margin-bottom: 0.75rem;
}
.skeleton-block.skeleton-flashcard {
  box-shadow: inset 0 0 0 1px var(--card-accent, transparent);
}
/* ============ VIEW ENTER ANIMATIONS ============ */
/* Slide-in when the skeleton or the results panel becomes visible.
   Combined with saved-view-mode, this makes the generate flow feel like
   a separate screen instead of inline content under the form. */

#skeletonContainer,
#resultsContainer {
  animation: viewEnter 0.4s cubic-bezier(0.2, 0.9, 0.3, 1);
}

@keyframes viewEnter {
  0%   { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  #skeletonContainer,
  #resultsContainer {
    animation: none;
  }
}

/* Staggered pulse for the "Generating…" hint */
.skeleton-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  opacity: 0.6;
}
.skeleton-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: skeletonDotPulse 1s ease-in-out infinite;
}
.skeleton-dot:nth-child(2) { animation-delay: 0.15s; }
.skeleton-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes skeletonDotPulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50%      { opacity: 1;   transform: scale(1.1); }
}

/* ============ PER-CARD / PER-QUESTION COLOR PALETTE ============ */

/* Each element gets `--card-accent`, `--card-soft`, `--card-border`
   set inline by JS. These rules consume them. */

/* --- Flashcards --- */
.flashcard .flashcard-front,
.flashcard .flashcard-back {
  border-color: var(--card-border, var(--border-card));
}
.flashcard .flashcard-front {
  background: linear-gradient(
    145deg,
    var(--card-soft, var(--bg-card-solid)) 0%,
    var(--bg-card-solid) 60%
  );
}
.flashcard .flashcard-front p:first-child {
  color: var(--card-accent, var(--text-body));
}
.flashcard:hover .flashcard-inner {
  box-shadow: 0 0 0 1px var(--card-border, transparent),
              0 8px 24px var(--card-soft, transparent);
}

/* --- Quiz questions --- */
.quiz-card {
  border-left: 3px solid var(--card-accent, var(--accent));
  background: linear-gradient(
    90deg,
    var(--card-soft, transparent) 0%,
    rgba(255, 255, 255, 0.04) 40%
  );
}
html.light .quiz-card {
  background: linear-gradient(
    90deg,
    var(--card-soft, transparent) 0%,
    rgba(0, 0, 0, 0.02) 40%
  );
}
.quiz-card .quiz-number {
  color: var(--card-accent, var(--accent));
}

/* --- Summary items --- */
.summary-item {
  border-left: 3px solid var(--card-accent, var(--accent));
  background: linear-gradient(
    90deg,
    var(--card-soft, transparent) 0%,
    rgba(255, 255, 255, 0.04) 45%
  );
}
html.light .summary-item {
  background: linear-gradient(
    90deg,
    var(--card-soft, transparent) 0%,
    rgba(0, 0, 0, 0.02) 45%
  );
}
.summary-item .summary-number {
  color: var(--card-accent, var(--accent));
}

/* --- Saved library + note cards --- */
.saved-card,
.note-card {
  border-left: 3px solid var(--card-accent, var(--border-card)) !important;
}

/* --- Study Mode big card --- */
#studyCard.has-accent {
  background: linear-gradient(
    145deg,
    var(--card-soft, var(--bg-card)) 0%,
    var(--bg-card) 70%
  );
  border-color: var(--card-border, var(--border-card));
}
#studyCard.has-accent #studyTerm {
  color: var(--card-accent, var(--text-body));
}

html.light #studyCard.has-accent {
  background: linear-gradient(
    145deg,
    var(--card-soft, rgba(0,0,0,0.03)) 0%,
    rgba(0,0,0,0.03) 70%
  );
  border-color: var(--card-border, var(--border-card));
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .skeleton-block { animation: none; }
  .skeleton-dot   { animation: none; opacity: 0.6; }
}

/* ============ THEME SYSTEM ============ */
:root {
  --radius-card: 1.5rem;
  --radius-btn: 0.75rem;
  --radius-input: 0.75rem;
  --radius-lg: 1rem;
  --card-blur: 12px;
  --density: 1;
}

/* Density affects paddings and gaps globally */
.density-compact  { --density: 0.85; }
.density-comfy    { --density: 1; }
.density-spacious { --density: 1.15; }

.glass-card {
  border-radius: var(--radius-card);
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  padding: calc(1.25rem * var(--density));
}
@media (min-width: 640px) {
  .glass-card {
    padding: calc(1.5rem * var(--density));
  }
}

.btn-primary,
input,
textarea,
select {
  border-radius: var(--radius-btn);
}
input,
textarea,
select {
  border-radius: var(--radius-input);
}

#flashcardGrid > .flashcard,
.skeleton-flashcard {
  border-radius: var(--radius-lg);
}

/* Preset card */
.theme-preset-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.4rem;
  border-radius: 0.75rem;
  border: 1px solid var(--border-card);
  background: var(--bg-card);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.theme-preset-card:hover {
  background: var(--bg-hover);
  transform: translateY(-1px);
}
.theme-preset-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.theme-preset-swatch {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.15);
}
html.light .theme-preset-swatch {
  border-color: rgba(0, 0, 0, 0.1);
}
.theme-preset-label {
  font-size: 0.65rem;
  font-weight: 600;
  opacity: 0.7;
}

/* Range slider styling */
input[type="range"] {
  width: 100%;
  height: 6px;
  padding: 0;
  background: var(--bg-input);
  border: none;
  border-radius: 9999px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

/* ============ ACCENT SYNC FOR TAILWIND INDIGO ============ */
button.bg-indigo-600,
.bg-indigo-600.rounded-lg,
.bg-indigo-600.rounded-xl {
  background: var(--accent) !important;
}
button.bg-indigo-600:hover,
.bg-indigo-600.rounded-lg:hover,
.bg-indigo-600.rounded-xl:hover {
  background: var(--accent2) !important;
}

.bg-indigo-600\/20 {
  background: rgba(var(--accent-rgb), 0.2) !important;
}
.bg-indigo-600\/30 {
  background: rgba(var(--accent-rgb), 0.3) !important;
}

.bg-indigo-500\/10 {
  background: rgba(var(--accent-rgb), 0.1) !important;
}
.bg-indigo-500\/20 {
  background: rgba(var(--accent-rgb), 0.2) !important;
}
.bg-indigo-500\/5 {
  background: rgba(var(--accent-rgb), 0.05) !important;
}

.text-indigo-400 {
  color: var(--accent) !important;
}
.text-indigo-300 {
  color: var(--accent2) !important;
}

#backToGeneratorBtn:not(.hidden) {
  animation: viewEnter 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}

/* ============ QUIZ TYPE TILES ============ */
.quiz-type-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .quiz-type-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
  }
}

.quiz-type-tile {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding: 0.7rem 0.75rem;
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.quiz-type-tile:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}
.quiz-type-tile:active {
  transform: scale(0.985);
}

/* Checked state — soft accent glow */
.quiz-type-tile:has(input[type="checkbox"]:checked) {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.35);
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.15) inset;
}
.quiz-type-tile:has(input[type="checkbox"]:checked):hover {
  background: rgba(99, 102, 241, 0.12);
  border-color: rgba(99, 102, 241, 0.5);
}

/* Head row: check + name */
.quiz-type-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

/* Custom checkbox visual */
.quiz-type-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  border-radius: 9999px;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  background: transparent;
  flex-shrink: 0;
  transition: background 0.15s, border-color 0.15s;
}
.quiz-type-check i {
  font-size: 0.55rem;
  color: #fff;
  opacity: 0;
  transition: opacity 0.15s;
}
.quiz-type-tile:has(input[type="checkbox"]:checked) .quiz-type-check {
  background: var(--accent, #6366f1);
  border-color: var(--accent, #6366f1);
}
.quiz-type-tile:has(input[type="checkbox"]:checked) .quiz-type-check i {
  opacity: 1;
}

.quiz-type-name {
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.1;
  color: var(--text-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.quiz-type-tile:not(:has(input[type="checkbox"]:checked)) .quiz-type-name {
  opacity: 0.55;
}

/* Count input inside the tile */
.quiz-type-count {
  width: 100%;
  padding: 0.4rem 0.5rem;
  text-align: center;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.5rem;
  color: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: opacity 0.15s, border-color 0.15s;
  cursor: text;
}
.quiz-type-count:hover {
  border-color: rgba(255, 255, 255, 0.2);
}
.quiz-type-count:focus {
  outline: none;
  border-color: var(--accent, #6366f1);
  background: rgba(0, 0, 0, 0.3);
}

/* Disabled (type off) — dim block input */
.quiz-type-tile:not(:has(input[type="checkbox"]:checked)) .quiz-type-count {
  opacity: 0.35;
  pointer-events: none;
}

/* Keyboard focus ring — shows on the tile, not on the hidden checkbox */
.quiz-type-tile:has(input[type="checkbox"]:focus-visible) {
  outline: 2px solid var(--accent, #6366f1);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .quiz-type-tile { transition: none; }
  .quiz-type-tile:active { transform: none; }
}

/* Light mode */
html.light .quiz-type-tile {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
html.light .quiz-type-tile:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.15);
}
html.light .quiz-type-tile:has(input[type="checkbox"]:checked) {
  background: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.4);
}
html.light .quiz-type-check {
  border-color: rgba(0, 0, 0, 0.18);
}
html.light .quiz-type-count {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(0, 0, 0, 0.1);
}

/* ============ HOME DASHBOARD ============ */
#viewHome {
  animation: viewEnter 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.due-subject-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
}

.due-subject-row .bar-track {
  width: 4rem;
  height: 0.375rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
  flex-shrink: 0;
}

html.light .due-subject-row .bar-track {
  background: rgba(0, 0, 0, 0.06);
}

.due-subject-row .bar-fill {
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}

#recentItemsList .note-card {
  border-left: none !important;
}

/* ============ DEADLINES ============ */
.deadline-row {
  transition: background 0.15s;
  border-radius: 0.5rem;
  padding: 0.4rem 0.35rem;
  margin: 0 -0.35rem;
}
.deadline-row:hover {
  background: var(--bg-hover);
}
html.light .deadline-row:hover {
  background: rgba(0, 0, 0, 0.04);
}
/* ============ GENERATE META TILES ============ */
.gen-meta-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.35rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s;
  color: var(--text-body);
}
.gen-meta-tile:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}
.gen-meta-tile.active {
  background: rgba(var(--accent-rgb), 0.15);
  border-color: rgba(var(--accent-rgb), 0.5);
  color: var(--accent2);
}

html.light .gen-meta-tile {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
html.light .gen-meta-tile:hover {
  background: rgba(0, 0, 0, 0.05);
}
html.light .gen-meta-tile.active {
  background: rgba(var(--accent-rgb), 0.12);
  color: var(--accent);
}

/* Library card meta line */
.saved-card .saved-meta-line {
  font-size: 0.7rem;
  opacity: 0.55;
  margin-top: 0.15rem;
}
.saved-card .saved-meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.05rem 0.4rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 0.65rem;
  font-weight: 600;
  margin-right: 0.25rem;
}
html.light .saved-card .saved-meta-chip {
  background: rgba(0, 0, 0, 0.05);
}

/* ============ HOME PROGRESS PILLS (streak + weekly XP) ============ */
.progress-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.32rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.progress-pill strong {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.progress-pill i {
  font-size: 0.75rem;
}

.progress-pill.streak {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.3);
  color: #fbbf24;
}
.progress-pill.streak i {
  color: #f59e0b;
}

.progress-pill.xp {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: var(--accent2);
}
.progress-pill.xp i {
  color: var(--accent);
}

html.light .progress-pill.streak {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}
html.light .progress-pill.xp {
  color: #4338ca;
}

/* ============================================================ */
/* REVIEWER REDESIGN — Approach A                               */
/* ============================================================ */

/* Input method tabs */
.input-method-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  border-radius: 0.6rem;
  margin-bottom: 0.75rem;
}
.input-method-tabs button {
  flex: 1;
  padding: 0.5rem;
  border-radius: 0.5rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.input-method-tabs button.active {
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent2);
}
.input-method-tabs button:hover:not(.active) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-body);
}

/* Quiz pills */
.quiz-pills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .quiz-pills {
    grid-template-columns: repeat(4, 1fr);
  }
}
.quiz-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  border-radius: 0.55rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.quiz-pill:hover {
  background: rgba(255, 255, 255, 0.06);
}
.quiz-pill.active {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.4);
}
.quiz-pill input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.quiz-pill input[type="number"] {
  width: 38px;
  padding: 0.15rem 0.25rem;
  text-align: center;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.35rem;
  flex-shrink: 0;
}
.quiz-pill span.flex-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Range slider styling for flashcard count */
#flashcardSlider {
  width: 100%;
  height: 6px;
  padding: 0;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  border-radius: 9999px;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
  accent-color: var(--accent);
}
#flashcardSlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
}

/* Sticky action bar — sits above the fixed bottom tab bar */
.sticky-action-bar {
  position: sticky;
  bottom: 5.5rem;
  z-index: 30;
  padding: 0.75rem 1.25rem 0.5rem;   /* ← was 0.75rem 0 0.5rem — added 1.25rem sides */
  margin-top: 0.5rem;
  background: linear-gradient(
    180deg,
    rgba(10, 10, 18, 0) 0%,
    rgba(10, 10, 18, 0.9) 40%,
    rgba(10, 10, 18, 1) 100%
  );
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* When the tab bar isn't at the bottom, still keep some gap */
@media (min-width: 1024px) {
  .sticky-action-bar {
    bottom: 1rem;
    padding-left: 1.5rem;      /* ← match desktop glass-card padding */
    padding-right: 1.5rem;
  }
}

/* Textarea live counter block */
#charCount, #wordCount {
  font-variant-numeric: tabular-nums;
}

/* Light mode adjustments */
html.light .quiz-pill {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
html.light .quiz-pill:hover {
  background: rgba(0, 0, 0, 0.05);
}
html.light .quiz-pill.active {
  background: rgba(var(--accent-rgb), 0.1);
  border-color: rgba(var(--accent-rgb), 0.4);
}
html.light .input-method-tabs {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
html.light #flashcardSlider {
  background: rgba(0, 0, 0, 0.08);
}
html.light .sticky-action-bar {
  background: linear-gradient(
    180deg,
    rgba(241, 245, 249, 0) 0%,
    rgba(241, 245, 249, 0.9) 40%,
    rgba(241, 245, 249, 1) 100%
  );
}

/* ============================================================ */
/* LIGHT MODE POLISH — depth, contrast, and color vibrancy      */
/* ============================================================ */

/* ----- Body: soft radial glow behind everything ----- */
/* IMPORTANT: no background-attachment: fixed — that forces a full
   repaint every scroll frame and was the cause of light-mode lag. */
html.light body {
  background: var(--bg-body);
}

/* ----- Cards: replace blur with crisp solid + shadow ----- */
html.light .glass-card {
  background: var(--bg-card);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border: 1px solid var(--border-card);
  box-shadow: var(--shadow-card);
}

/* Hover state for interactive cards */
html.light .glass-card.btn-hover:hover,
html.light .note-card:hover,
html.light .saved-card:hover {
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.05),
    0 8px 20px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(var(--accent-rgb), 0.15);
  border-color: rgba(var(--accent-rgb), 0.25);
}

/* ----- Header card: crisp accent bar ----- */
html.light #mainWrapper > .glass-card.header {
  background: linear-gradient(135deg, #ffffff 0%, #f8fafc 100%);
}

/* ----- Tab bar: prominent, elevated ----- */
html.light #tabContainer {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-card);
  border-bottom: none;
  box-shadow:
    0 -1px 0 rgba(15, 23, 42, 0.04),
    0 -8px 24px rgba(15, 23, 42, 0.08);
}

/* Active tab: solid accent background with white text */
html.light #tabContainer button.tab-active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.35);
}

html.light #tabContainer button.tab-active i {
  color: #ffffff;
}

/* Inactive tabs: dark text for contrast */
html.light #tabContainer button.tab-inactive {
  color: #64748b;
}

html.light #tabContainer button.tab-inactive:hover {
  background: rgba(var(--accent-rgb), 0.08);
  color: var(--accent);
}

/* ----- Inputs: clearer borders, subtle inset ----- */
html.light input,
html.light textarea,
html.light select {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.02);
}

html.light input:focus,
html.light textarea:focus,
html.light select:focus {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(var(--accent-rgb), 0.12),
    inset 0 1px 2px rgba(15, 23, 42, 0.02);
  background: #ffffff;
}

/* ----- Primary buttons: stronger shadow ----- */
html.light .btn-primary {
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.3);
}

html.light .btn-primary:hover {
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.4);
}

/* ----- Gradient text: darker colors for readability ----- */
html.light .bg-gradient-to-r.from-indigo-400.to-cyan-300,
html.light h1.bg-gradient-to-r {
  background: linear-gradient(to right, var(--accent), #0891b2) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  color: transparent !important;
  -webkit-text-fill-color: transparent !important;
}

/* ----- Flashcard front/back: solid, elevated ----- */
html.light .flashcard-front,
html.light .flashcard-back {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-card);
  box-shadow:
    0 1px 3px rgba(15, 23, 42, 0.06),
    0 4px 12px rgba(15, 23, 42, 0.04);
}

/* ----- Quiz options: clearly clickable ----- */
html.light .quiz-option {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

html.light .quiz-option:hover {
  background: #f8fafc;
  border-color: rgba(var(--accent-rgb), 0.4);
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.1);
}

/* ----- Modals: heavier backdrop, crisper card ----- */
html.light [data-modal] {
  background: rgba(15, 23, 42, 0.35) !important;
}

html.light [data-modal] > .glass-card {
  box-shadow:
    0 20px 50px rgba(15, 23, 42, 0.2),
    0 4px 12px rgba(15, 23, 42, 0.08),
    0 0 0 1px rgba(15, 23, 42, 0.04);
}

/* ----- Subject / quiz pills: filled when active ----- */
html.light .quiz-pill.active {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.5);
}

html.light .subject-filter-pill.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.25);
}

html.light .subject-filter-pill.active .note-subject-dot {
  background: rgba(255, 255, 255, 0.9) !important;
}

/* ----- Gen meta tiles: solid fill when active ----- */
html.light .gen-meta-tile.active {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.25);
}

/* ----- Progress pills: richer colors ----- */
html.light .progress-pill.streak {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  border-color: rgba(245, 158, 11, 0.4);
  color: #b45309;
}

html.light .progress-pill.xp {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  border-color: rgba(var(--accent-rgb), 0.3);
  color: #3730a3;
}

/* ----- Status dots: darker borders ----- */
html.light .status-dot.online {
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

html.light .status-dot.offline {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

html.light .status-dot.checking {
  background: #94a3b8;
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}

/* ----- Skeleton loaders: warmer shimmer ----- */
html.light .skeleton-block {
  background: linear-gradient(
    90deg,
    #e2e8f0 0%,
    #f1f5f9 50%,
    #e2e8f0 100%
  );
  background-size: 200% 100%;
}

html.light .skeleton-card {
  background: #ffffff;
  border: 1px solid var(--border-card);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
}

/* ----- Results nav: cleaner active state ----- */
html.light .results-nav-btn.active {
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(var(--accent-rgb), 0.2);
}

html.light .results-nav-count {
  background: rgba(15, 23, 42, 0.06);
  color: #475569;
}

/* ----- Splash screen: light gradient + softer glows ----- */
html.light .splash-screen {
  background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
}

html.light .splash-glow-1 {
  background: radial-gradient(circle, rgba(var(--accent-rgb), 0.18) 0%, transparent 70%);
  opacity: 0.7;
}

html.light .splash-glow-2 {
  background: radial-gradient(circle, rgba(6, 182, 212, 0.15) 0%, transparent 70%);
  opacity: 0.6;
}

html.light .splash-logo-inner {
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.04) inset,
    0 8px 32px rgba(var(--accent-rgb), 0.25),
    0 0 60px rgba(6, 182, 212, 0.15);
}

html.light .splash-tagline {
  color: #64748b;
}

html.light .splash-footer {
  color: #94a3b8;
}

html.light .splash-progress-bar {
  background: rgba(15, 23, 42, 0.06);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.03);
}

html.light .splash-progress-text {
  color: #64748b;
}

/* Particles: darker, more visible */
html.light .particle {
  color: var(--accent);
  opacity: 0.10;
}

/* ----- Deadline rows: brighter hover ----- */
html.light .deadline-row:hover {
  background: rgba(var(--accent-rgb), 0.06);
}

/* ----- Calendar: brighter day cells ----- */
html.light .calendar-day {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

html.light .calendar-day:hover {
  background: #f8fafc;
  border-color: var(--accent);
}

html.light .calendar-day.today {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background: rgba(var(--accent-rgb), 0.05);
}

html.light .calendar-day.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(var(--accent-rgb), 0.3);
}

/* Keep type-colored dots, but add a white halo ring so they stay
   visible against the indigo selection background. */
html.light .calendar-day.selected .task-dot {
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.85);
}

/* ----- Yellow/green/rose accents: darker for contrast ----- */
html.light .text-amber-400 { color: #d97706 !important; }
html.light .text-emerald-400 { color: #059669 !important; }
html.light .text-rose-400 { color: #dc2626 !important; }
html.light .text-cyan-400 { color: #0891b2 !important; }
html.light .text-teal-400 { color: #0d9488 !important; }

/* Alert/pill backgrounds slightly more saturated */
html.light .bg-amber-500\/10 { background: rgba(245, 158, 11, 0.12) !important; }
html.light .bg-emerald-500\/10 { background: rgba(16, 185, 129, 0.1) !important; }
html.light .bg-rose-500\/10 { background: rgba(239, 68, 68, 0.08) !important; }
html.light .bg-indigo-500\/10 { background: rgba(var(--accent-rgb), 0.08) !important; }

/* Study mode card: crisper in light */
html.light #studyCard {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
  border: 1px solid var(--border-card);
  box-shadow:
    0 4px 12px rgba(15, 23, 42, 0.06),
    0 12px 32px rgba(15, 23, 42, 0.04);
}

/* Study mode action buttons: solid pastels */
html.light button[onclick*="rateStudyCard('forgot')"] {
  background: #fef2f2;
  border-color: rgba(239, 68, 68, 0.3);
  color: #b91c1c;
}

html.light button[onclick*="rateStudyCard('hard')"] {
  background: #fffbeb;
  border-color: rgba(245, 158, 11, 0.3);
  color: #b45309;
}

html.light button[onclick*="rateStudyCard('easy')"] {
  background: #ecfdf5;
  border-color: rgba(16, 185, 129, 0.3);
  color: #047857;
}

/* ----- Toast notifications: brighter ----- */
html.light #appNotification {
  box-shadow:
    0 4px 16px rgba(15, 23, 42, 0.12),
    0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ----- Backend "checking" pulse ----- */
html.light .status-dot.checking {
  animation: statusPulseLight 1.4s ease-in-out infinite;
}

@keyframes statusPulseLight {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}

/* ----- Reduced motion: keep everything static ----- */
@media (prefers-reduced-motion: reduce) {
  html.light body {
    background-attachment: scroll;
  }
}

/* Quiz pills */
.quiz-pills {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}
@media (min-width: 640px) {
  .quiz-pills {
    grid-template-columns: repeat(4, 1fr);
  }
}
.quiz-pill {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.65rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-card);
  border-radius: 0.55rem;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
  -webkit-user-select: none;
  min-width: 0; /* FIX: Allows the grid item to shrink */
  width: 100%;  /* FIX: Ensures it fills the grid cell */
}
.quiz-pill:hover {
  background: rgba(255, 255, 255, 0.06);
}
.quiz-pill.active {
  background: rgba(var(--accent-rgb), 0.12);
  border-color: rgba(var(--accent-rgb), 0.4);
}
.quiz-pill input[type="checkbox"] {
  width: auto;
  padding: 0;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.quiz-pill input[type="number"] {
  width: 45px; /* FIX: Wider to fit 2 digits comfortably */
  padding: 0.15rem 0.25rem;
  text-align: center;
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.35rem;
  flex-shrink: 0; /* FIX: Prevents input from squishing */
}
.quiz-pill span.flex-1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0; /* FIX: Allows text to truncate */
}

/* Stack pills on very small screens to prevent cramping */
@media (max-width: 380px) {
  .quiz-pills {
    grid-template-columns: 1fr;
  }
}

/* ============================================================ */
/* MOBILE PERFORMANCE OPTIMIZATIONS                             */
/* ============================================================ */

/* Prevent rubber-band bounce scrolling which causes repaints */
html, body {
  overscroll-behavior-y: none;
}

@media (max-width: 768px) {
  
  /* 1. Kill expensive blur effects on mobile */
  .glass-card,
  #tabContainer,
  #resultsNav,
  .backdrop-blur-sm,
  .sm\:backdrop-blur-sm,
  [data-modal] > .glass-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* 2. Give the no-blur elements solid backgrounds to maintain contrast */
  html:not(.light) .glass-card {
    background: var(--bg-card-solid) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: none !important; /* Shadows also cost rendering power */
  }
  
  html.light .glass-card {
    background: #ffffff !important;
    border-color: rgba(15, 23, 42, 0.08) !important;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06) !important;
  }

  /* 3. Solid backgrounds for fixed navigation bars */
  html:not(.light) #tabContainer, 
  html:not(.light) #resultsNav {
    background: var(--bg-body) !important;
    border-top: 1px solid var(--border-card) !important;
  }
  
  html.light #tabContainer,
  html.light #resultsNav {
    background: #ffffff !important;
    border-top: 1px solid rgba(15, 23, 42, 0.08) !important;
  }

  /* 4. Hardware accelerate fixed elements */
  #tabContainer {
    transform: translateX(-50%) translateZ(0);
    will-change: transform;
  }
  
  /* 5. Disable splash screen particles on mobile to free up GPU */
  .splash-particles {
    display: none !important;
  }
  
  .splash-glow {
    animation: none !important;
    opacity: 0.3 !important;
  }
}

/* ============================================================ */
/* MCQ STUDY MODE                                               */
/* ============================================================ */
.mcq-study-option {
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.mcq-study-option:not(:disabled):hover {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.mcq-study-option.mcq-correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
  color: #34d399;
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.2) inset;
}

.mcq-study-option.mcq-wrong {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: #f87171;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.2) inset;
}

html.light .mcq-study-option {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
}
html.light .mcq-study-option:not(:disabled):hover {
  background: #f8fafc;
  border-color: rgba(var(--accent-rgb), 0.4);
}
html.light .mcq-study-option.mcq-correct {
  background: #ecfdf5 !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
  color: #047857;
}
html.light .mcq-study-option.mcq-wrong {
  background: #fef2f2 !important;
  border-color: rgba(239, 68, 68, 0.5) !important;
  color: #b91c1c;
}

/* ============================================================ */
/* HOME DASHBOARD UPGRADE                                       */
/* ============================================================ */

/* ---- Hero greeting card ---- */
.home-hero {
  background: linear-gradient(
    145deg,
    rgba(var(--accent-rgb), 0.06) 0%,
    var(--bg-card) 60%
  );
}
html.light .home-hero {
  background: linear-gradient(145deg, #ffffff 0%, #f8fafc 100%);
}

/* ---- Level badge ---- */
.home-level-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  padding: 0.5rem 0.85rem;
  border-radius: 0.85rem;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(var(--accent-rgb), 0.35);
  flex-shrink: 0;
  min-width: 62px;
}
.home-level-num {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.home-level-label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.9;
}

/* ---- Level progress bar ---- */
.home-level-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 9999px;
  overflow: hidden;
}
html.light .home-level-track {
  background: rgba(15, 23, 42, 0.06);
}
.home-level-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 9999px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Quick stats row ---- */
.home-stat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.7rem 0.4rem;
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 0.85rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  backdrop-filter: blur(var(--card-blur));
  -webkit-backdrop-filter: blur(var(--card-blur));
  text-align: center;
  min-width: 0;
  font-family: inherit;
  color: var(--text-body);
}
.home-stat-card:hover {
  background: var(--bg-hover);
  border-color: rgba(var(--accent-rgb), 0.25);
}
.home-stat-card:active {
  transform: scale(0.97);
}
.home-stat-card i {
  font-size: 0.95rem;
}
.home-stat-num {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin-top: 0.15rem;
}
.home-stat-label {
  font-size: 0.6rem;
  font-weight: 600;
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ---- Weekly activity chart ---- */
.weekly-chart {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.4rem;
  align-items: end;
  height: 100px;
  padding: 0 0.2rem;
}
.weekly-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 0.35rem;
  height: 100%;
  min-width: 0;
}
.weekly-bar {
  width: 100%;
  max-width: 28px;
  border-radius: 0.35rem;
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
  min-height: 3px;
}
.weekly-bar.no-xp {
  background: rgba(255, 255, 255, 0.06);
}
html.light .weekly-bar.no-xp {
  background: rgba(15, 23, 42, 0.05);
}
.weekly-bar.has-xp {
  background: linear-gradient(180deg, var(--accent2), var(--accent));
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.3);
}
.weekly-bar.is-today {
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.35), 0 2px 8px rgba(var(--accent-rgb), 0.3);
}
.weekly-bar-label {
  font-size: 0.62rem;
  font-weight: 700;
  opacity: 0.45;
  text-transform: uppercase;
  line-height: 1;
}
.weekly-bar-label.is-today {
  opacity: 1;
  color: var(--accent);
}

/* Mobile performance: drop blur on mobile */
@media (max-width: 768px) {
  .home-stat-card {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: var(--bg-card-solid) !important;
  }
  .home-hero {
    background: var(--bg-card-solid) !important;
  }
}

/* Light mode: brighter stat cards */
html.light .home-stat-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
html.light .home-stat-card:hover {
  background: #f8fafc;
  border-color: rgba(var(--accent-rgb), 0.35);
  box-shadow: 0 4px 12px rgba(var(--accent-rgb), 0.1);
}

/* ============================================================ */
/* CALENDAR UPGRADE                                             */
/* ============================================================ */

/* ---- Month stats chips ---- */
.calendar-stat-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.25);
  color: var(--accent2);
  white-space: nowrap;
}
.calendar-stat-chip i {
  font-size: 0.7rem;
}
.calendar-stat-chip.upcoming {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.28);
  color: #fbbf24;
}
.calendar-stat-chip.overdue {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.28);
  color: #f87171;
}
.calendar-stat-chip.muted {
  background: rgba(148, 163, 184, 0.08);
  border-color: rgba(148, 163, 184, 0.2);
  color: var(--text-secondary);
}
html.light .calendar-stat-chip {
  color: var(--accent);
}
html.light .calendar-stat-chip.upcoming { color: #b45309; }
html.light .calendar-stat-chip.overdue { color: #b91c1c; }

/* ---- Multi-dot day cells ---- */
.calendar-day .task-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  justify-content: center;
  flex-wrap: nowrap;
}
.calendar-day .task-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
  /* override the old margin-top */
  margin-top: 0;
}
.calendar-day .task-count {
  font-size: 0.55rem;
  font-weight: 700;
  opacity: 0.7;
  margin-left: 1px;
  line-height: 1;
}

/* ---- Overdue day tint ---- */
.calendar-day.overdue-day {
  background: rgba(239, 68, 68, 0.06);
}
html.light .calendar-day.overdue-day {
  background: rgba(239, 68, 68, 0.05);
}
.calendar-day.overdue-day.selected {
  background: rgba(239, 68, 68, 0.12);
}
html.light .calendar-day.overdue-day.selected {
  background: rgba(239, 68, 68, 0.1);
}

/* Selected day wins over overdue-day styling */
.calendar-day.selected.overdue-day {
  border-color: #ef4444;
}

/* ---- Deadline count badge in day panel ---- */
.deadline-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.35rem;
  border-radius: 9999px;
  background: rgba(var(--accent-rgb), 0.2);
  color: var(--accent2);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1;
}
html.light .deadline-count-badge {
  color: var(--accent);
}

/* ---- Empty day state ---- */
.empty-day-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 0;
}

/* ---- Deadline card ---- */
.deadline-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.6rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.deadline-card:hover {
  background: rgba(var(--accent-rgb), 0.08);
  border-color: rgba(var(--accent-rgb), 0.3);
}
.deadline-card:active {
  transform: scale(0.99);
}
.deadline-card-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

html.light .deadline-card {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
}
html.light .deadline-card:hover {
  background: #f8fafc;
  border-color: rgba(var(--accent-rgb), 0.35);
}

/* ---- Upcoming strip ---- */
.upcoming-item {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.7rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0.6rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.upcoming-item:hover {
  background: rgba(var(--accent-rgb), 0.06);
  border-color: rgba(var(--accent-rgb), 0.28);
}
.upcoming-item:active {
  transform: scale(0.99);
}
.upcoming-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.upcoming-today-tag {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.4rem;
  border-radius: 9999px;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent2);
  vertical-align: middle;
}
html.light .upcoming-item {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
}
html.light .upcoming-item:hover {
  background: #f8fafc;
  border-color: rgba(var(--accent-rgb), 0.35);
}
html.light .upcoming-today-tag {
  color: var(--accent);
}

/* ---- Today button polish ---- */
#calendarTodayBtn {
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#calendarTodayBtn:hover {
  background: rgba(var(--accent-rgb), 0.15) !important;
  color: var(--accent2);
}
html.light #calendarTodayBtn:hover {
  color: var(--accent);
}

/* ---- Calendar grid: prevent text selection during swipe ---- */
#calendarGrid {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}

/* ---- Light mode tweaks for the day cells ---- */
html.light .calendar-day.overdue-day:hover {
  background: rgba(239, 68, 68, 0.08);
}

/* ---- Compact calendar on small phones ---- */
@media (max-width: 380px) {
  .calendar-day {
    min-height: 52px;
    font-size: 0.75rem;
  }
  .calendar-day-header {
    font-size: 0.65rem;
  }
}

/* ---- Mobile performance: no blur ---- */
@media (max-width: 768px) {
  .deadline-card,
  .upcoming-item {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* ============================================================ */
/* CALENDAR — TYPES, FILTERS, COMPLETION, AGENDA                */
/* ============================================================ */

/* ---- View toggle ---- */
.calendar-view-toggle {
  display: flex;
  gap: 0.15rem;
  padding: 0.2rem;
  border-radius: 0.6rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-card);
}
.calendar-view-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  border-radius: 0.45rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.calendar-view-btn.active {
  background: rgba(var(--accent-rgb), 0.18);
  color: var(--accent2);
}
.calendar-view-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.06);
}
html.light .calendar-view-btn.active {
  color: var(--accent);
}

/* ---- Type filter chips ---- */
.calendar-type-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 9999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.calendar-type-filter:hover {
  background: rgba(255, 255, 255, 0.08);
}
.calendar-type-filter:active {
  transform: scale(0.97);
}
.calendar-type-filter.active {
  background: var(--type-color, var(--accent));
  border-color: var(--type-color, var(--accent));
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.calendar-type-filter-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  flex-shrink: 0;
}
.calendar-type-filter.active .calendar-type-filter-dot {
  background: rgba(255, 255, 255, 0.95) !important;
}
html.light .calendar-type-filter {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.08);
  color: #475569;
}
html.light .calendar-type-filter:hover {
  background: #f8fafc;
}

/* ---- Deadline type chips (in sheet) ---- */
.deadline-type-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.7rem;
  border-radius: 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-body);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.deadline-type-chip:hover {
  background: rgba(255, 255, 255, 0.07);
}
.deadline-type-chip:active {
  transform: scale(0.97);
}
.deadline-type-chip.active {
  background: var(--type-color);
  border-color: var(--type-color);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.deadline-type-chip i {
  font-size: 0.68rem;
}
html.light .deadline-type-chip {
  background: #ffffff;
  border-color: rgba(15, 23, 42, 0.1);
}

/* ---- Load indicator (heavy day) ---- */
.calendar-day.heavy-load {
  box-shadow: 0 0 0 1.5px rgba(239, 68, 68, 0.45);
}
.calendar-day.heavy-load.today {
  box-shadow: 0 0 0 1.5px rgba(239, 68, 68, 0.6),
              0 0 0 3px rgba(239, 68, 68, 0.15);
}
html.light .calendar-day.heavy-load {
  box-shadow: 0 0 0 1.5px rgba(239, 68, 68, 0.4);
}

/* ---- Completed item styling ---- */
.deadline-card.is-done {
  opacity: 0.55;
}
.deadline-card.is-done p {
  text-decoration: line-through;
}
.deadline-card.is-done .deadline-type-icon {
  filter: grayscale(0.6);
}
.calendar-day .task-dot.is-done {
  background: rgba(148, 163, 184, 0.6) !important;
}

/* Circular check toggle */
.deadline-check {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  border: 1.5px solid var(--border-card);
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  color: transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.deadline-check:hover {
  border-color: rgba(var(--accent-rgb), 0.5);
}
.deadline-check:active {
  transform: scale(0.9);
}
.deadline-check i {
  font-size: 0.6rem;
}
.deadline-check.is-done {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}
html.light .deadline-check {
  border-color: rgba(15, 23, 42, 0.15);
}
html.light .deadline-check.is-done {
  background: #10b981;
  border-color: #10b981;
  color: #fff;
}

/* ---- Type icon on cards ---- */
.deadline-type-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.72rem;
  color: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.deadline-type-icon-sm {
  width: 1.4rem;
  height: 1.4rem;
  font-size: 0.6rem;
  border-radius: 0.4rem;
}

/* ---- Done stats chip ---- */
.calendar-stat-chip.done {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.28);
  color: #34d399;
}
html.light .calendar-stat-chip.done {
  color: #047857;
}

/* ---- Agenda view ---- */
.agenda-day {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.agenda-day-header {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.15rem 0.1rem;
}
.agenda-day-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-body);
}
.agenda-day-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
  font-size: 0.6rem;
  font-weight: 700;
  background: rgba(var(--accent-rgb), 0.15);
  color: var(--accent2);
  letter-spacing: 0.02em;
}
html.light .agenda-day-badge {
  color: var(--accent);
}
.agenda-empty {
  text-align: center;
  padding: 2.5rem 1rem;
}

/* ---- Day cell: prevent text selection + long-press menu ---- */
.calendar-day {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---- Mobile tweaks ---- */
@media (max-width: 768px) {
  .deadline-type-chip,
  .calendar-type-filter,
  .calendar-view-toggle {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}

/* Light mode polish */
html.light .deadline-type-icon {
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

/* ============================================================ */
/* OFFLINE BANNER                                               */
/* ============================================================ */
.offline-banner {
  position: fixed;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: offlineSlideDown 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
  pointer-events: none;
  max-width: calc(100vw - 2rem);
}
.offline-banner.hidden {
  display: none;
}
.offline-banner i {
  font-size: 0.8rem;
}

@keyframes offlineSlideDown {
  from { opacity: 0; transform: translate(-50%, -12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

html.light .offline-banner {
  background: #fffbeb;
  border-color: rgba(245, 158, 11, 0.4);
  color: #b45309;
}

@media (max-width: 768px) {
  .offline-banner {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background: rgba(245, 158, 11, 0.95);
    color: #1f1f1f;
    border-color: transparent;
  }
  html.light .offline-banner {
    background: #f59e0b;
    color: #ffffff;
  }
}
/* ============================================================ */
/* DEADLINE TYPE CHIP — VISIBILITY SAFETY NET                  */
/* ============================================================ */

/* Guarantee icon + label are always visible, even if a stylesheet
   or font-family override tries to hide them. */
.deadline-type-chip {
  color: var(--text-body) !important;
  -webkit-text-fill-color: currentColor !important;
  background-clip: border-box !important;
  -webkit-background-clip: border-box !important;
}

.deadline-type-chip i {
  color: inherit;
  flex-shrink: 0;
  min-width: 0.7rem;      /* prevent collapse if icon fails */
  display: inline-block;
}

.deadline-type-chip.active {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

/* Fallback if --type-color ever fails to resolve */
.deadline-type-chip.active {
  background: var(--type-color, var(--accent));
  border-color: var(--type-color, var(--accent));
}

/* ============================================================ */
/* CALENDAR DOT — BULLETPROOF OVERRIDE                          */
/* ============================================================ */

/* Container: guarantee room for up to 3 dots side-by-side */
.calendar-day .task-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 3px;
  flex-wrap: nowrap;
  min-height: 8px;
}

/* Dot: bigger, thicker border, forces type color to survive any
   background tint (overdue red, selected indigo, today accent). */
.calendar-day .task-dot {
  width: 7px !important;
  height: 7px !important;
  border-radius: 50%;
  display: inline-block;
  margin-top: 0 !important;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
  /* NOTE: background is set inline by JS — never override here. */
}

/* Only completed items get the muted gray treatment */
.calendar-day .task-dot.is-done {
  background: rgba(148, 163, 184, 0.6) !important;
  border-color: rgba(255, 255, 255, 0.5);
}

/* On SELECTED days: brighten the halo but keep the type color */
.calendar-day.selected .task-dot {
  border-color: rgba(255, 255, 255, 0.95);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.08),
    0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Fix: SELECTED + OVERDUE → use indigo selection, NOT red tint.
   Selection is the stronger state — overdue is still conveyed by
   the countdown text and the type color of the dots. */
html.light .calendar-day.selected.overdue-day,
html:not(.light) .calendar-day.selected.overdue-day {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-color: transparent;
  color: #ffffff;
}

/* Amber "+N" overflow badge — nicer alignment */
.calendar-day .task-count {
  font-size: 0.6rem !important;
  font-weight: 800 !important;
  opacity: 0.9 !important;
  margin-left: 2px !important;
  line-height: 1;
  color: inherit;
}

/* ============================================================ */
/* TOUCH PARTICLES                                              */
/* ============================================================ */

/* ============================================================ */
/* TOUCH PARTICLES — HIGH VISIBILITY                            */
/* ============================================================ */

#touchParticlesLayer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
  contain: strict;
}

/* ---- Sparkle particle ---- */
.tp-particle {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 1;
  animation: tpFly var(--tp-duration, 0.7s) cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
  /* Layered glow: tight core + soft halo */
  box-shadow:
    0 0 10px 2px var(--tp-color, #a5b4fc),
    0 0 20px 4px color-mix(in srgb, var(--tp-color, #a5b4fc) 45%, transparent);
  will-change: transform, opacity;
}

@keyframes tpFly {
  0% {
    transform: translate(-50%, -50%) scale(0.45);
    opacity: 1;
  }
  40% {
    opacity: 1;
  }
  100% {
    transform:
      translate(calc(-50% + var(--tp-dx, 0px)), calc(-50% + var(--tp-dy, 0px)))
      scale(0.15);
    opacity: 0;
  }
}

/* ---- Glow ripple at impact ---- */
.tp-ripple {
  position: absolute;
  width: 140px;
  height: 140px;
  transform: translate(-50%, -50%) scale(0.05);
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(
    circle,
    var(--tp-color, #a5b4fc) 0%,
    color-mix(in srgb, var(--tp-color, #a5b4fc) 40%, transparent) 35%,
    transparent 70%
  );
  opacity: 0.75;
  animation: tpRipple 0.7s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
  will-change: transform, opacity;
}

@keyframes tpRipple {
  0% {
    transform: translate(-50%, -50%) scale(0.05);
    opacity: 0.85;
  }
  100% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 0;
  }
}

/* ---- Secondary expanding ring (crisp outline) ---- */
.tp-ring {
  position: absolute;
  width: 60px;
  height: 60px;
  transform: translate(-50%, -50%) scale(0.15);
  border-radius: 50%;
  pointer-events: none;
  border: 3px solid var(--tp-color, #a5b4fc);
  opacity: 0.9;
  animation: tpRing 0.55s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
  will-change: transform, opacity;
  box-shadow: 0 0 12px var(--tp-color, #a5b4fc);
}

@keyframes tpRing {
  0% {
    transform: translate(-50%, -50%) scale(0.15);
    opacity: 0.95;
    border-width: 4px;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.3);
    opacity: 0;
    border-width: 1px;
  }
}

/* ============================================================ */
/* LIGHT MODE — MAXIMUM VISIBILITY                              */
/* ============================================================ */
html.light .tp-particle {
  /* Heavier glow for white background */
  box-shadow:
    0 0 12px 3px var(--tp-color, #6366f1),
    0 0 24px 6px color-mix(in srgb, var(--tp-color, #6366f1) 50%, transparent);
  opacity: 1;
}

html.light .tp-ripple {
  opacity: 0.65;
  /* Add a subtle dark outer edge so the ripple is visible on white */
  filter: drop-shadow(0 0 6px color-mix(in srgb, var(--tp-color, #6366f1) 40%, transparent));
}

html.light .tp-ring {
  border-width: 3.5px;
  opacity: 1;
  box-shadow: 0 0 10px var(--tp-color, #6366f1);
}

/* ============================================================ */
/* DARK MODE — Enhanced (previously too subtle)                 */
/* ============================================================ */
html:not(.light) .tp-particle {
  box-shadow:
    0 0 12px 2px var(--tp-color, #a5b4fc),
    0 0 28px 6px color-mix(in srgb, var(--tp-color, #a5b4fc) 40%, transparent);
}

html:not(.light) .tp-ring {
  border-width: 3px;
  box-shadow: 0 0 14px var(--tp-color, #a5b4fc);
}

/* Respect reduced-motion: hide everything */
@media (prefers-reduced-motion: reduce) {
  .tp-particle,
  .tp-ripple,
  .tp-ring {
    display: none !important;
  }
}
/* ============ SHARED REVIEWER VIEW ============ */

/* Hide the generator form entirely while viewing a shared/saved reviewer.
   Reuses the existing saved-view-mode class so no JS view flags are needed. */
#viewReviewer.saved-view-mode .input-method-tabs,
#viewReviewer.saved-view-mode #reviewerGeneratePane > .glass-card,
#viewReviewer.saved-view-mode .sticky-action-bar {
  display: none !important;
}

/* Compact shared strip */
.shared-strip {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.7rem;
  border-radius: 0.85rem;
  background: linear-gradient(
    135deg,
    rgba(245, 158, 11, 0.10) 0%,
    var(--bg-card) 60%
  );
  border: 1px solid rgba(245, 158, 11, 0.28);
  animation: viewEnter 0.35s cubic-bezier(0.2, 0.9, 0.3, 1);
}
.shared-strip.is-dismissing {
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s, transform 0.25s;
}

.shared-strip-icon {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.6rem;
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.shared-strip-body { flex: 1; min-width: 0; }

.shared-strip-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.shared-strip-badge {
  font-size: 0.6rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #fbbf24;
  background: rgba(245, 158, 11, 0.16);
  padding: 0.1rem 0.45rem;
  border-radius: 9999px;
}
.shared-strip-date {
  font-size: 0.65rem;
  opacity: 0.5;
}

.shared-strip-title {
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shared-strip-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}
.shared-strip-author {
  font-size: 0.7rem;
  opacity: 0.7;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.shared-strip-save {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.55rem;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.shared-strip-save:hover { background: var(--accent2); }
.shared-strip-save:active { transform: scale(0.97); }

.shared-strip-close {
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  border: none;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  flex-shrink: 0;
  transition: background 0.15s;
}
.shared-strip-close:hover { background: rgba(255, 255, 255, 0.12); }

html.light .shared-strip {
  background: linear-gradient(135deg, #fffbeb 0%, #ffffff 60%);
  border-color: rgba(245, 158, 11, 0.35);
}
html.light .shared-strip-close {
  background: rgba(15, 23, 42, 0.05);
}
html.light .shared-strip-close:hover {
  background: rgba(15, 23, 42, 0.09);
}
.hidden { display: none !important; }

/* ============================================================ */
/* SAVED LIST — SORT, FILTER, MASTERY, EXTEND                   */
/* ============================================================ */

#savedSortSelect {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: 0.55rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-body);
  cursor: pointer;
  width: auto !important;
  max-width: 10rem;
}

/* Type tag pill (Reviewer / Summary) */
.saved-type-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.08rem 0.45rem;
  border-radius: 9999px;
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.saved-type-tag.reviewer {
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
}
.saved-type-tag.summary {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
}
html.light .saved-type-tag.reviewer { color: #4338ca; }
html.light .saved-type-tag.summary { color: #b45309; }

/* Mastery progress bar in card */
.saved-mastery {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.saved-mastery-track {
  flex: 1;
  height: 4px;
  max-width: 110px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}
html.light .saved-mastery-track {
  background: rgba(15, 23, 42, 0.06);
}
.saved-mastery-fill {
  height: 100%;
  background: linear-gradient(90deg, #10b981, #34d399);
  border-radius: 9999px;
  transition: width 0.4s ease;
}
.saved-mastery-label {
  font-size: 0.63rem;
  font-weight: 700;
  opacity: 0.65;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Extend button on Reviewer cards */
.saved-extend-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.55rem;
  border-radius: 0.45rem;
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  font-size: 0.68rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.saved-extend-btn:hover { background: rgba(16, 185, 129, 0.2); }
.saved-extend-btn:active { transform: scale(0.96); }
html.light .saved-extend-btn { color: #047857; }

/* Extend-mode banner above the generator form */
#extendBanner {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.10) 0%, var(--bg-card) 60%);
  border: 1px solid rgba(16, 185, 129, 0.28);
  border-left-width: 4px !important;
  border-left-color: #10b981 !important;
  border-radius: 0.85rem;
  padding: 0.6rem 0.75rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  animation: viewEnter 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
html.light #extendBanner {
  background: linear-gradient(135deg, #ecfdf5 0%, #ffffff 60%);
}
/* ============================================================ */
/* SUBMIT BUTTON — SINGLE-LINE LABEL                            */
/* ============================================================ */

/* Force the button label to stay on one line and ellipsize
   if the title is still too long, instead of wrapping and
   turning the sticky bar into a two-story block. */
#submitBtn #btnContent {
  display: inline-block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  vertical-align: middle;
}

/* Let the flex row handle shrinking gracefully */
#submitBtn {
  min-width: 0;
}

#submitBtn > * {
  min-width: 0;
}

/* ============================================================ */
/* TODAY'S STUDY PLAN — REDESIGN                                */
/* ============================================================ */

/* --- Hero: ring + number + meta chips --- */
.sp-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.sp-ring-wrap {
  position: relative;
  width: 92px;
  height: 92px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
}

.sp-ring {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}
.sp-ring circle {
  fill: none;
  stroke-width: 5;
  stroke-linecap: round;
}
.sp-ring-track {
  stroke: rgba(255, 255, 255, 0.06);
}
html.light .sp-ring-track {
  stroke: rgba(15, 23, 42, 0.06);
}
.sp-ring-fill {
  stroke: var(--accent);
  stroke-dasharray: 100;         /* Normalized via pathLength */
  stroke-dashoffset: 100;         /* Empty by default */
  transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.sp-ring-num {
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.sp-meta {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}
.sp-label {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.1;
}
.sp-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.35;
}

/* --- Chips --- */
.sp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.sp-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
  white-space: nowrap;
  line-height: 1;
}
.sp-chip i { font-size: 9px; }

.sp-chip.sp-new {
  background: rgba(99, 102, 241, 0.10);
  color: #6366f1;
  border-color: rgba(99, 102, 241, 0.22);
}
.sp-chip.sp-review {
  background: rgba(16, 185, 129, 0.10);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.22);
}
.sp-chip.sp-time {
  background: rgba(148, 163, 184, 0.10);
  color: var(--text-secondary);
  border-color: rgba(148, 163, 184, 0.20);
}
.sp-chip.sp-xp {
  background: rgba(245, 158, 11, 0.10);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.25);
}
html.light .sp-chip.sp-new { color: #4338ca; }
html.light .sp-chip.sp-review { color: #047857; }
html.light .sp-chip.sp-xp { color: #b45309; }

/* Hide chips when value is zero so the row stays clean */
.sp-chip.is-empty { display: none; }

/* --- Mix bar --- */
.sp-mix-bar {
  display: flex;
  height: 6px;
  border-radius: 9999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  margin-bottom: 14px;
}
html.light .sp-mix-bar {
  background: rgba(15, 23, 42, 0.05);
}
.sp-mix-seg {
  display: block;
  height: 100%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.sp-mix-new    { background: #818cf8; }
.sp-mix-review { background: #34d399; }

/* --- Subject list --- */
.sp-subjects {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 16px;
}

.sp-subject-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  border: 1px solid transparent;
}
.sp-subject-row:hover {
  background: var(--bg-hover);
  border-color: var(--border-card);
}
.sp-subject-row:active { transform: scale(0.99); }

.sp-subject-dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.sp-subject-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-body);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sp-subject-start {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  opacity: 0;
  transition: opacity 0.15s;
  white-space: nowrap;
}
.sp-subject-row:hover .sp-subject-start { opacity: 1; }

.sp-subject-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 96px;
}
.sp-subject-bar {
  flex: 1;
  height: 5px;
  min-width: 44px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 9999px;
  overflow: hidden;
}
html.light .sp-subject-bar {
  background: rgba(15, 23, 42, 0.06);
}
.sp-subject-bar > span {
  display: block;
  height: 100%;
  border-radius: 9999px;
  transition: width 0.4s ease;
}
.sp-subject-count {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-body);
  font-variant-numeric: tabular-nums;
  min-width: 20px;
  text-align: right;
}

/* --- CTA --- */
.sp-cta-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 13px 20px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: #fff;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(var(--accent-rgb), 0.32);
  transition: box-shadow 0.2s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}
.sp-cta-primary:hover {
  box-shadow: 0 8px 22px rgba(var(--accent-rgb), 0.42);
}
.sp-cta-primary:active { transform: translateY(0) scale(0.99); }
.sp-cta-primary i:not(.sp-cta-arrow) { font-size: 11px; }
.sp-cta-primary span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sp-cta-arrow {
  font-size: 11px;
  transition: transform 0.2s;
}
.sp-cta-primary:hover .sp-cta-arrow { transform: translateX(3px); }

.sp-cta-secondary {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 9px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: rgba(148, 163, 184, 0.3);
  text-underline-offset: 3px;
  transition: color 0.15s, text-decoration-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.sp-cta-secondary:hover {
  color: var(--accent);
  text-decoration-color: rgba(var(--accent-rgb), 0.5);
}

/* --- Footline --- */
.sp-footline {
  margin: 12px 0 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--text-secondary);
  opacity: 0.7;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.sp-footline i { font-size: 10px; color: var(--accent); }

/* --- Mobile: tighten a bit --- */
@media (max-width: 380px) {
  .sp-ring-wrap { width: 78px; height: 78px; }
  .sp-ring-num  { font-size: 26px; }
  .sp-hero      { gap: 12px; }
  .sp-label     { font-size: 13px; }
  .sp-subject-right { min-width: 84px; }
}

/* --- Drop blur for mobile perf --- */
@media (max-width: 768px) {
  .sp-cta-primary { backdrop-filter: none; -webkit-backdrop-filter: none; }
}

/* ============================================================ */
/* ONBOARDING TOUR                                              */
/* ============================================================ */

body.tour-active {
  overflow: hidden;
}

#tourRoot {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
}
#tourRoot[aria-hidden="true"] {
  display: none;
}

.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.62);
  pointer-events: auto;
  animation: tourFadeIn 0.25s ease-out;
}

html.light .tour-overlay {
  background: rgba(15, 23, 42, 0.55);
}

.tour-spotlight {
  position: fixed;
  pointer-events: none;
  border-radius: 12px;
  box-shadow:
    0 0 0 9999px rgba(0, 0, 0, 0),
    0 0 0 3px var(--accent, #6366f1),
    0 0 30px rgba(99, 102, 241, 0.45);
  transition: top 0.28s cubic-bezier(0.2, 0.9, 0.3, 1),
              left 0.28s cubic-bezier(0.2, 0.9, 0.3, 1),
              width 0.28s cubic-bezier(0.2, 0.9, 0.3, 1),
              height 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  z-index: 1;
}

html.light .tour-spotlight {
  box-shadow:
    0 0 0 9999px rgba(15, 23, 42, 0),
    0 0 0 3px var(--accent, #6366f1),
    0 0 30px rgba(99, 102, 241, 0.35);
}

.tour-tooltip {
  position: fixed;
  width: min(320px, calc(100vw - 24px));
  background: var(--bg-card-solid, #1a1a2e);
  color: var(--text-body, #e2e8f0);
  border: 1px solid var(--border-card, rgba(255,255,255,0.1));
  border-radius: 14px;
  padding: 1rem 1.05rem;
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  z-index: 2;
  pointer-events: auto;
  animation: tourPopIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

html.light .tour-tooltip {
  background: #ffffff;
  color: #0f172a;
  border-color: rgba(15, 23, 42, 0.1);
  box-shadow:
    0 20px 50px rgba(15, 23, 42, 0.2),
    0 4px 12px rgba(15, 23, 42, 0.08);
}

.tour-tooltip::before {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: inherit;
  border: inherit;
  transform: rotate(45deg);
  left: var(--tour-arrow-x, 30px);
}
.tour-tooltip.tour-arrow-top::before {
  top: -7px;
  border-right: none;
  border-bottom: none;
}
.tour-tooltip.tour-arrow-bottom::before {
  bottom: -7px;
  border-left: none;
  border-top: none;
}

.tour-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.35rem;
  color: var(--text-body, #e2e8f0);
}
html.light .tour-title {
  color: #0f172a;
}

.tour-body {
  font-size: 0.8rem;
  line-height: 1.5;
  opacity: 0.75;
  margin: 0 0 0.85rem;
}

.tour-progress {
  display: flex;
  gap: 5px;
  margin-bottom: 0.65rem;
}
.tour-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.18);
  transition: background 0.2s, width 0.2s;
}
html.light .tour-dot {
  background: rgba(15, 23, 42, 0.15);
}
.tour-dot.active {
  width: 18px;
  background: var(--accent, #6366f1);
}

.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tour-btn-group {
  display: flex;
  gap: 0.4rem;
}

.tour-btn {
  padding: 0.45rem 0.8rem;
  border-radius: 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.tour-btn:active { transform: scale(0.97); }

.tour-btn-next {
  background: var(--accent, #6366f1);
  color: #ffffff;
  border-color: var(--accent, #6366f1);
}
.tour-btn-next:hover {
  background: var(--accent2, #818cf8);
  border-color: var(--accent2, #818cf8);
}

.tour-btn-prev {
  background: rgba(255, 255, 255, 0.06);
  color: inherit;
  border-color: var(--border-card, rgba(255,255,255,0.1));
}
.tour-btn-prev:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}
.tour-btn-prev:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

html.light .tour-btn-prev {
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.1);
}
html.light .tour-btn-prev:hover:not(:disabled) {
  background: #e2e8f0;
}

.tour-btn-skip {
  background: transparent;
  color: inherit;
  opacity: 0.55;
  padding: 0.45rem 0.4rem;
  font-size: 0.7rem;
}
.tour-btn-skip:hover {
  opacity: 1;
  text-decoration: underline;
}

@keyframes tourFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes tourPopIn {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .tour-overlay,
  .tour-tooltip,
  .tour-spotlight {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================ */
/* SETTINGS TOGGLES FIX (LIGHT MODE)                            */
/* ============================================================ */
html.light #settingsThemeToggle,
html.light #settingsSoundToggle,
html.light #settingsParticlesToggle {
  background-color: #cbd5e1 !important; /* Visible slate/gray track */
  border: 1px solid #94a3b8 !important; /* Clear border */
}

html.light #settingsThemeDot,
html.light #settingsSoundDot,
html.light #settingsParticlesDot {
  background-color: #ffffff !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important; /* Shadow so the white dot is visible */
}

/* Dark mode enhancement (optional, to make them look premium) */
html:not(.light) #settingsThemeToggle,
html:not(.light) #settingsSoundToggle,
html:not(.light) #settingsParticlesToggle {
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
}
html:not(.light) #settingsThemeDot,
html:not(.light) #settingsSoundDot,
html:not(.light) #settingsParticlesDot {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5) !important;
}
