/* Match the contact form's circular return control without obscuring the page. */
html body button.public-back-to-top {
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
    z-index: 100;
    display: grid;
    place-items: center;
    width: 48px;
    min-width: 48px;
    height: 48px;
    min-height: 48px;
    margin: 0;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: transparent !important;
    box-shadow: 0 3px 12px rgb(24 62 48 / 12%);
    cursor: pointer;
    touch-action: manipulation;
    opacity: 1;
}
html body button.public-back-to-top:is(:hover, :focus-visible) { opacity: 1; }
html body .public-back-to-top[hidden] { display: none !important; }
html body .public-back-to-top .page-back-icon {
    width: 48px;
    height: 48px;
    color: #146d42;
    background: #eaf7ef;
    border: 1px solid #8cae99;
    border-radius: 50%;
}
html body .public-back-to-top .page-back-icon::before {
    width: 28px;
    height: 28px;
    transform: translate(-50%, -50%) rotate(90deg);
    -webkit-mask: var(--rounded-arrow-mask) center / contain no-repeat;
    mask: var(--rounded-arrow-mask) center / contain no-repeat;
}
html body .public-back-to-top:is(:hover, :focus-visible) .page-back-icon {
    color: #fff;
    background: #168552;
    border-color: #146d42;
}
html body .public-back-to-top:focus-visible { outline: 3px solid #ad6a19; outline-offset: 3px; }
html body .back-to-top-heading:focus:not(:focus-visible) { outline: none; }
html body .back-to-top-heading:focus-visible { outline: 2px solid #ad6a19; outline-offset: 5px; }
/* Local development controls occupy the bottom corner; production stays at 12px. */
body:has(> iframe[src*="debug-kit/toolbar/"]) .public-back-to-top,
html:not(.developer-toolbar-hidden) body:has(.developer-tools) .public-back-to-top {
    bottom: calc(64px + env(safe-area-inset-bottom));
}
/* A solid overlay at the bottom edge; it does not reserve workspace width. */
html body:has(.workspace-shell) button.public-back-to-top[data-workspace-back-to-top] {
    right: max(12px, env(safe-area-inset-right));
    bottom: calc(8px + env(safe-area-inset-bottom));
}
/* The local debug iframe spans the bottom strip, including its transparent area. */
html body:has(> iframe[src*="debug-kit/toolbar/"]) button.public-back-to-top[data-workspace-back-to-top] {
    z-index: 100000;
}
body:has([data-cookie-banner]:not([hidden])) .public-back-to-top,
html.system-dialog-open .public-back-to-top,
body:has(dialog[open]) .public-back-to-top,
body:has(.developer-tools details[open]) .public-back-to-top {
    visibility: hidden;
}
html[data-theme='dark'] body .public-back-to-top .page-back-icon {
    background: #1c3326;
    color: #aff0ca;
    border-color: #789d88;
}
html[data-theme='dark'] body .public-back-to-top:is(:hover, :focus-visible) .page-back-icon { color: #fff; background: #168552; border-color: #aff0ca; }
html[data-theme='dark'] body :is(.public-back-to-top, .back-to-top-heading):focus-visible { outline-color: #ebbf7d; }
html[data-high-contrast='1'] body .public-back-to-top .page-back-icon { background: #eaf7ef; color: #07562c; border-color: #07562c; }
html[data-theme='dark'][data-high-contrast='1'] body .public-back-to-top .page-back-icon { background: #101b14; color: #afffce; border-color: #afffce; }
@media (prefers-reduced-motion: reduce) {
    html body .public-back-to-top .page-back-icon { transition: none; }
}
