.scroll-to-top {
    position: fixed;
    bottom: 40px;
    right: 35px;
    z-index: 102;
    width: 47px;
    height: 47px;
    box-sizing: border-box;
    border: 1px solid var(--fb-border-accent, var(--fb-blue));
    border-radius: 15%;
    background-color: var(--fb-bg-accent, var(--fb-blue));
    color: var(--fb-text-invert, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: scale(0);
    transform-origin: center;
    transition: opacity 0.3s ease, visibility 0.3s ease, background-color 0.3s ease, transform 0.3s ease, color 0.3s ease;
    box-shadow: var(--fb-shadow-md, 0 4px 6px -1px rgba(0,0,0,0.08));
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.scroll-to-top.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.scroll-to-top:hover {
    background-color: var(--fb-bg-accent-subtle, var(--fb-blue-low));
    color: var(--fb-text-accent, var(--fb-blue));
    border-color: var(--fb-border-accent, var(--fb-blue));
    box-shadow: var(--fb-shadow-lg, 0 10px 15px -3px rgba(0,0,0,0.08));
}

.scroll-to-top:active {
    background-color: var(--fb-blue-high);
    color: var(--fb-text-invert, #fff);
    transition: background-color 0.1s ease, transform 0.1s ease;
}

.scroll-to-top.keyboard-focus {
    outline: var(--fb-focus-ring-width, 2px) solid var(--fb-focus-ring, var(--fb-blue));
    outline-offset: var(--fb-focus-ring-offset, 2px);
}

.scroll-to-top svg:not(.scroll-progress-ring) {
    width: 35px;
    height: 35px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    position: relative;
    z-index: 1;
}

/* Tooltip */
.scroll-to-top-tooltip {
    position: absolute;
    right: -22px;
    top: -47px;
    background-color: var(--fb-gray-7, #1e293b);
    color: var(--fb-text-invert, #fff);
    padding: 5px 10px;
    border-radius: var(--fb-radius-sm, 4px);
    font-weight: var(--fb-weight-normal, 400);
    font-size: var(--fb-text-sm, 14px);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.3s;
    pointer-events: none;
}

.scroll-to-top-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-to-top-tooltip-arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--fb-gray-7, #1e293b);
}

:root.dark .scroll-to-top-tooltip {
    background-color: var(--fb-gray-7);
    color: var(--fb-gray-1);
}

:root.dark .scroll-to-top-tooltip-arrow {
    border-top-color: var(--fb-gray-7);
}

/* Progress ring */
.scroll-progress-ring {
    pointer-events: none;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.scroll-progress-track {
    stroke: var(--scroll-progress-color, currentColor);
    opacity: 0.2;
}

.scroll-progress-circle {
    stroke: var(--scroll-progress-color, currentColor);
    stroke-dasharray: 138.23;
    stroke-dashoffset: 138.23;
    transition: stroke-dashoffset 0.1s ease;
}

/* Mobile */
@media (max-width: 768px) {
    .scroll-to-top {
        bottom: 1.25rem;
        right: 1.25rem;
        width: 40px;
        height: 40px;
    }

    .scroll-to-top svg {
        width: 28px;
        height: 28px;
    }
}

@media print {
    .scroll-to-top {
        display: none !important;
    }
}
