.katex-display {
  position: relative;
}

.katex-display .math-copy-btn {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 2;
  background: transparent;
  border: none;
  color: #888;
  padding: 2px 6px;
  font-size: 1em;
  cursor: pointer;
}

.katex-display:hover .math-copy-btn {
  opacity: 1;
}

.katex.math-copy-inline {
  cursor: pointer;
  border-radius: 3px;
}

/* Tooltip styling */
.math-copy-tooltip {
  position: absolute;
  background: #333;
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.9em;
  white-space: nowrap;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.math-copy-tooltip.show {
  opacity: 1;
}