.fdm-back-to-top {
    position: fixed;
    right: 20px;
    bottom: var(--fdm-back-to-top-bottom, calc(20px + env(safe-area-inset-bottom, 0px)));
    z-index: 9999;
    box-sizing: border-box;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #ebebeb;
    border-radius: 50%;
    background: #fff;
    color: #333;
    cursor: pointer;
    appearance: none;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .2s, visibility .2s, border-color .2s;
    -webkit-tap-highlight-color: transparent;
}
.fdm-back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.fdm-back-to-top svg {
    display: block;
    width: 24px;
    height: 24px;
}
/* Reserve the button height plus a 20px gap, including the coffee stack. */
@media (max-width: 767px) {
    body:has(#fdm-back-to-top) footer,
    body:has(#fdm-back-to-top) #footer {
        padding-bottom: calc(var(--fdm-back-to-top-bottom, calc(20px + env(safe-area-inset-bottom, 0px))) + 50px);
    }
}
.fdm-back-to-top:focus-visible {
    outline: 2px solid #16a4fa;
}
@media (hover: hover) and (pointer: fine) {
    .fdm-back-to-top:hover { border-color: #16a4fa;}
}
@media (prefers-reduced-motion: reduce) {
    .fdm-back-to-top { transition: none; }
}
