:root {
  --bg0: #070A12;
  --bg1: #0B1020;
  --card: #0C1226cc;
  --card2: #0B132B;
  --text: #EAF0FF;
  --muted: #AAB7E6;
  --line: #1B2550;
  --a: #7C4DFF;
  --b: #00E5FF;
  --c: #00FFB3;
  --shadow: 0 18px 60px rgba(0, 0, 0, .55);
  --shadow2: 0 12px 40px rgba(0, 0, 0, .45);
  --radius: 18px;
}

* {
  box-sizing: border-box
}

html,
body {
  height: 100%
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: radial-gradient(1200px 800px at 20% 10%, rgba(124, 77, 255, .18), transparent 55%),
    radial-gradient(1000px 650px at 80% 0%, rgba(0, 229, 255, .12), transparent 60%),
    radial-gradient(900px 650px at 60% 100%, rgba(0, 255, 179, .10), transparent 55%),
    linear-gradient(180deg, var(--bg0), var(--bg1));
  overflow: hidden;
}

/* Background layers */
.bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg__grid {
  position: absolute;
  inset: -2px;
  background:
    linear-gradient(to right, rgba(255, 255, 255, .06) 1px, transparent 1px) 0 0/64px 64px,
    linear-gradient(to bottom, rgba(255, 255, 255, .045) 1px, transparent 1px) 0 0/64px 64px;
  mask-image: radial-gradient(900px 600px at 35% 20%, black 30%, transparent 70%);
  opacity: .35;
  transform: translateZ(0);
  animation: floatGrid 26s ease-in-out infinite;
}

@keyframes floatGrid {

  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1)
  }

  50% {
    transform: translate3d(0, -4px, 0) scale(1.01)
  }
}

.bg__glow {
  position: absolute;
  width: 680px;
  height: 680px;
  border-radius: 999px;
  filter: blur(50px);
  opacity: .22;
  transform: translateZ(0);
  animation: drift 32s ease-in-out infinite;
}

.bg__glow--a {
  left: -240px;
  top: -260px;
  background: radial-gradient(circle at 30% 30%, rgba(124, 77, 255, .85), transparent 60%);
}

.bg__glow--b {
  right: -260px;
  bottom: -280px;
  background: radial-gradient(circle at 30% 30%, rgba(0, 229, 255, .75), transparent 62%);
  animation-duration: 40s;
}

@keyframes drift {

  0%,
  100% {
    transform: translate3d(0, 0, 0) scale(1)
  }

  50% {
    transform: translate3d(12px, 6px, 0) scale(1.01)
  }
}

.bg__particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: .75;
}

/* Flashcard layout */
.flash-root {
  position: relative;
  height: 100vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.flash-stage {
  position: relative;
  width: 100%;
  max-width: 440px;
  height: 100%;
  max-height: 760px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 10px;
}

.flash-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-inline: 4px;
}

.flash-btn {
  flex: 0 0 auto;
  min-width: 80px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(27, 37, 80, .9);
  background: radial-gradient(circle at 0 0, rgba(124, 77, 255, .32), transparent 60%),
    radial-gradient(circle at 100% 0, rgba(0, 229, 255, .28), transparent 65%),
    rgba(7, 10, 18, .8);
  color: var(--text);
  font-size: 13px;
  font-weight: 650;
  letter-spacing: .1px;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
  transition: transform .1s ease, box-shadow .1s ease, border-color .1s ease, background .15s ease;
}

.flash-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, .65);
  border-color: rgba(0, 229, 255, .7);
}

.flash-btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 22px rgba(0, 0, 0, .6);
}

.flash-index {
  flex: 1 1 auto;
  text-align: center;
  font-size: 12px;
  color: rgba(170, 183, 230, .96);
}

.flash-hint {
  text-align: center;
  font-size: 12px;
  color: rgba(170, 183, 230, .95);
  text-shadow: 0 2px 10px rgba(0, 0, 0, .7);
  pointer-events: none;
}

@media (max-width: 480px) {
  .flash-stage {
    max-width: 100%;
    max-height: 100%;
  }
}

/* Card */
.card {
  position: relative;
  border-radius: var(--radius);
  border: 1px solid rgba(27, 37, 80, .85);
  background: linear-gradient(180deg, rgba(12, 18, 38, .72), rgba(10, 16, 32, .42));
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateZ(0);
  transition: transform .2s ease, border-color .2s ease;
  isolation: isolate;
  min-height: 65vh;
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .card {
    min-height: 60vh;
  }
}

.card::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: radial-gradient(600px 240px at var(--mx, 40%) var(--my, 20%), rgba(0, 229, 255, .18), transparent 55%),
    radial-gradient(520px 240px at calc(var(--mx, 40%) + 10%) calc(var(--my, 20%) + 30%), rgba(124, 77, 255, .20), transparent 60%);
  opacity: 0;
  transition: opacity .2s ease;
  z-index: 0;
}

.card::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(124, 77, 255, .0), rgba(124, 77, 255, .18), rgba(0, 229, 255, .0));
  transform: translateX(-120%);
  opacity: .6;
  z-index: 0;
  pointer-events: none;
}

.card:hover {
  transform: translateY(-3px);
  border-color: rgba(0, 229, 255, .55);
}

.card:hover::before {
  opacity: 1;
}

.card:hover::after {
  animation: sweep 1.2s ease;
}

@keyframes sweep {
  to {
    transform: translateX(120%);
  }
}

.card__inner {
  position: relative;
  z-index: 1;
  padding: 16px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.badgeRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(27, 37, 80, .8);
  background: rgba(7, 10, 18, .35);
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.metaRow {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.metaChip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(7, 10, 18, .7);
  border: 1px solid rgba(27, 37, 80, .9);
  color: rgba(186, 199, 245, .96);
  font-size: 13px;
  font-weight: 650;
}

.card__note {
  margin-top: 14px;
  padding: 12px;
  background: rgba(124, 77, 255, 0.08);
  /* slight purple tint */
  border: 1px solid rgba(124, 77, 255, 0.3);
  border-left: 3px solid var(--b);
  /* Cyan accent */
  border-radius: 8px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.revealRow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.revealBtn,
.toggleBtn {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 8px;
  border-radius: 999px;
  border: 1px solid rgba(27, 37, 80, .9);
  background: radial-gradient(circle at 0 0, rgba(124, 77, 255, .3), transparent 60%),
    radial-gradient(circle at 100% 0, rgba(0, 229, 255, .24), transparent 65%),
    rgba(7, 10, 18, .88);
  color: var(--text);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .08px;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .5);
  text-align: center;
}

.revealBtn:hover,
.toggleBtn:hover {
  border-color: rgba(0, 229, 255, .7);
}

.revealBtn:active,
.toggleBtn:active {
  transform: translateY(1px);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .6);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--a), var(--b));
  box-shadow: 0 0 0 4px rgba(124, 77, 255, .14);
}

.card__title {
  font-weight: 780;
  letter-spacing: -.2px;
  font-size: 18px;
  margin: 0;
}

.card__eq {
  border-radius: 14px;
  border: 1px solid rgba(27, 37, 80, .85);
  background: linear-gradient(180deg, rgba(7, 10, 18, .35), rgba(7, 10, 18, .18));
  padding: 12px 20px;
  overflow-x: auto;
  overflow-y: auto;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  font-size: clamp(14px, 2.1vh, 18px);
  max-width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
}

.card__eq .mjx-chtml {
  font-size: 115%;
  margin: 0;
  max-width: 100%;
}

/* Custom scrollbar for equation area (mobile + desktop) */
.card__eq::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.card__eq::-webkit-scrollbar-track {
  background: rgba(7, 10, 18, .6);
  border-radius: 999px;
}

.card__eq::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, rgba(124, 77, 255, .9), rgba(0, 229, 255, .9));
  border-radius: 999px;
}

.card__eq {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 77, 255, .9) rgba(7, 10, 18, .6);
}

.card__hint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Entry animation */
@media (prefers-reduced-motion: no-preference) {
  .card {
    animation: pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    animation-delay: var(--delay, 0ms);
  }

  @keyframes pop {
    from {
      opacity: 0;
      transform: translateY(20px) scale(0.92);
      filter: blur(4px);
    }

    to {
      opacity: 1;
      transform: translateY(0) scale(1);
      filter: blur(0);
    }
  }
}

/* Navigation Drawer */
.menu-btn {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(27, 37, 80, 0.8);
  background: rgba(7, 10, 18, 0.6);
  backdrop-filter: blur(12px);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  background: rgba(124, 77, 255, 0.2);
  border-color: rgba(124, 77, 255, 0.5);
}

.nav-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s;
}

.nav-overlay.open {
  opacity: 1;
  visibility: visible;
}

.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 320px;
  max-width: 85vw;
  background: rgba(11, 16, 32, 0.95);
  border-left: 1px solid rgba(124, 77, 255, 0.2);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.7);
  z-index: 160;
  transform: translateX(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
  display: flex;
  flex-direction: column;
}

.nav-drawer.open {
  transform: translateX(0);
}

.nav-header {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.nav-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(90deg, #fff, #AAB7E6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.close-btn:hover {
  color: #fff;
}

.nav-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 77, 255, 0.4) transparent;
}

.nav-content::-webkit-scrollbar {
  width: 4px;
}

.nav-content::-webkit-scrollbar-thumb {
  background: rgba(124, 77, 255, 0.4);
  border-radius: 4px;
}

.chapter-group {
  margin-bottom: 20px;
}

.chapter-title {
  padding: 8px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--b);
  font-weight: 700;
  opacity: 0.8;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  margin-bottom: 4px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

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

.nav-item.active {
  background: rgba(124, 77, 255, 0.15);
  border-color: rgba(124, 77, 255, 0.3);
  color: #fff;
  font-weight: 600;
}

/* Footer & About Modal */
.app-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px;
  text-align: center;
  z-index: 50;
  background: linear-gradient(0deg, rgba(7, 10, 18, 0.9), transparent);
  pointer-events: none;
  /* Let clicks pass through empty space */
}

.app-footer p {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--muted);
  opacity: 0.7;
}

.footer-btn {
  pointer-events: auto;
  background: transparent;
  border: none;
  color: var(--b);
  font-size: 12px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 8px;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.footer-btn:hover {
  opacity: 1;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(5px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  padding: 20px;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: var(--bg1);
  border: 1px solid rgba(124, 77, 255, 0.3);
  border-radius: 20px;
  padding: 30px;
  max-width: 400px;
  width: 100%;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  transform: translateY(20px);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-align: center;
}

.modal-overlay.open .modal-card {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 24px;
  cursor: pointer;
  padding: 5px;
  line-height: 1;
}

.modal-card h2 {
  margin: 0 0 15px;
  font-size: 22px;
  background: linear-gradient(90deg, #fff, var(--b));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
  margin-bottom: 15px;
}

.modal-links {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-top: 20px;
}

.modal-links a {
  color: var(--a);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.modal-links a:hover {
  text-decoration: underline;
}

.profile-container {
  margin-bottom: 20px;
}

.profile-img {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid rgba(124, 77, 255, 0.3);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.social-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 24px;
}

.social-links a {
  color: var(--muted);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
}

.social-links a:hover {
  color: #fff;
  transform: translateY(-3px);
  background: rgba(124, 77, 255, 0.2);
  box-shadow: 0 5px 15px rgba(124, 77, 255, 0.3);
}