.footnote-button {
    position: relative;
    top: -0.1em;
    width: 3em;
    height: 2em;
    margin: 0 0.1em 0 0.2em;
    padding: 0.35em;
    border: 0;
    border-radius: 1em;
    background: rgba(0, 0, 0, 0.7);
    color: rgba(255, 255, 255, 0.75);
    font: bold 1rem / 1 sans-serif;
    vertical-align: middle;
    cursor: pointer;
}

.footnote-button:hover,
.footnote-button.is-active,
.footnote-button:focus-visible {
    background: rgba(255, 0, 225, 0.6);
    color: white;
}

.footnote-button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    box-shadow: 0 0 0 5px #19002e;
}

.footnote-popover {
    position: fixed;
    inset: auto;
    width: 22em;
    max-width: calc(100vw - 24px);
    max-height: 300px;
    margin: 0;
    padding: 0;
    border: 1px solid #c3c3c3;
    border-radius: 0.5em;
    background: white;
    color: #19002e;
    box-shadow: 0 0 8px rgb(0 0 0 / 30%);
    font-size: 2rem;
    line-height: normal;
    overflow: visible;
    overflow-wrap: anywhere;
}

.footnote-content {
    position: relative;
    z-index: 1;
    padding: 1.1em 1.3em 1.2em;
    max-height: 300px;
    overflow: auto;
    overscroll-behavior: contain;
    border-radius: inherit;
    background: inherit;
}

.footnote-popover::before {
    content: '';
    position: absolute;
    top: -7px;
    left: var(--pointer-left, 50%);
    width: 12px;
    height: 12px;
    background: inherit;
    border: inherit;
    transform: translateX(-50%) rotate(45deg);
}

.footnote-popover.is-above::before { top: auto; bottom: -7px; }
.footnote-content > :first-child { margin-top: 0; }
.footnote-content > :last-child { margin-bottom: 0; }

@media (prefers-color-scheme: dark) {
    .footnote-button { background: rgba(255, 0, 225, 0.6); }
    .footnote-popover { background: rgb(202, 0, 179); color: white; }
}

@media not print {
    .footnote-original { display: none !important; }
}

@media print {
    .footnote-button,
    .footnote-popover { display: none !important; }
}
