.footnote-popup {
  position: fixed;
  z-index: 9999;
  display: block;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-2px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 0ms linear 120ms;
  pointer-events: none;
}

.footnote-popup.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 120ms ease, transform 120ms ease, visibility 0ms;
  pointer-events: auto;
}

.footnote-popup__inner {
  max-width: min(520px, calc(100vw - 24px));
  max-height: min(60vh, 520px);
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  /* Don't rely on inheriting page text color; the popup background is controlled here. */
  color: #1d1f21;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.18);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  font-size: 0.95rem;
  line-height: 1.45;
}

.footnote-popup__inner a {
  color: #0b5fff;
  text-decoration: underline;
  background-image: none;
}

.footnote-popup__inner a:visited {
  color: #6a38ff;
}

.footnote-popup__inner p:last-child {
  margin-bottom: 0;
}

@media (prefers-color-scheme: dark) {
  .footnote-popup__inner {
    border-color: rgba(255, 255, 255, 0.14);
    background: rgba(25, 25, 25, 0.97);
    box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  }

  /* Some theme CSS sets explicit colors on elements (p/li/etc). Force readable text inside the popup. */
  .footnote-popup__inner,
  .footnote-popup__inner * {
    color: rgba(255, 255, 255, 0.92);
  }

  .footnote-popup__inner a {
    color: rgba(140, 200, 255, 0.95);
    text-decoration: underline;
    background-image: none;
  }

  .footnote-popup__inner a:visited {
    color: rgba(186, 156, 255, 0.9);
  }

  .footnote-popup__inner code,
  .footnote-popup__inner pre {
    background: rgba(255, 255, 255, 0.08);
    color: inherit;
  }
}

@media (prefers-reduced-motion: reduce) {
  .footnote-popup,
  .footnote-popup.is-visible {
    transition: none;
    transform: none;
  }
}


