.floating-menu {
    --menu-accent: var(--coral, #c86d4a);
    --active-index: 0;
    position: fixed;
    z-index: 120;
    right: 50%;
    bottom: calc(18px + env(safe-area-inset-bottom));
    display: grid;
    width: min(500px, calc(100vw - 32px));
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 8px;
    transform: translateX(50%);
    border: 1px solid rgba(28, 39, 34, .06);
    border-radius: 999px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 18px 48px rgba(23, 34, 29, .16), 0 3px 10px rgba(23, 34, 29, .08);
    color: #5b625e;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

body {
    padding-bottom: 100px;
}

.floating-link {
    position: relative;
    z-index: 1;
    display: flex;
    min-width: 0;
    min-height: 62px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: color .22s ease, background .22s ease;
}

.floating-link svg {
    display: block;
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.8;
    transition: color .22s ease, transform .36s cubic-bezier(.22, 1, .36, 1);
}

.floating-link small {
    overflow: hidden;
    max-width: 100%;
    font: 600 10px/1.1 "DM Sans", sans-serif;
    letter-spacing: .015em;
    text-overflow: ellipsis;
}

.floating-link:hover,
.floating-link[aria-current="page"],
.floating-pages[open] > .floating-link {
    color: var(--menu-accent);
}

.floating-link:hover svg,
.floating-link[aria-current="page"] svg,
.floating-pages[open] > .floating-link svg {
    transform: translateY(-1px);
}

.floating-pages {
    position: relative;
    min-width: 0;
}

.floating-pages > summary {
    list-style: none;
}

.floating-pages > summary::-webkit-details-marker {
    display: none;
}

.floating-mega-menu {
    position: absolute;
    right: 50%;
    bottom: calc(100% + 18px);
    display: grid;
    width: min(320px, calc(100vw - 32px));
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 4px;
    padding: 14px;
    transform: translateX(50%);
    border: 1px solid rgba(28, 39, 34, .07);
    border-radius: 18px;
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 16px 44px rgba(23, 34, 29, .17);
    transform-origin: bottom center;
    animation: floating-menu-enter .32s cubic-bezier(.22, 1, .36, 1) both;
}

.floating-mega-menu p {
    grid-column: 1 / -1;
    padding: 2px 8px 8px;
    color: #858b87;
    font: 700 9px/1.2 "DM Sans", sans-serif;
    letter-spacing: .14em;
    text-transform: uppercase;
}

.floating-mega-menu a {
    padding: 11px 9px;
    border-radius: 9px;
    color: #303832;
    font: 500 12px/1.2 "DM Sans", sans-serif;
    text-decoration: none;
    transition: color .2s ease, background .2s ease;
}

.floating-mega-menu a:hover,
.floating-mega-menu a[aria-current="page"] {
    background: rgba(200, 109, 74, .09);
    color: var(--menu-accent);
}

.floating-indicator {
    position: absolute;
    z-index: 0;
    top: -13px;
    left: 8px;
    width: calc((100% - 16px) / 4);
    height: 29px;
    transform: translateX(calc(var(--active-index) * 100%));
    transition: transform .52s cubic-bezier(.22, 1, .36, 1);
    pointer-events: none;
}

.floating-menu.is-initializing .floating-indicator {
    transition: none;
}

.floating-indicator::before {
    position: absolute;
    top: 0;
    left: 50%;
    width: 12px;
    height: 12px;
    transform: translateX(-50%);
    border: 3px solid #fff;
    border-radius: 50%;
    background: var(--menu-accent);
    box-shadow: 0 2px 8px rgba(200, 109, 74, .35);
    content: "";
}

.floating-indicator::after {
    position: absolute;
    right: 50%;
    bottom: 0;
    width: 26px;
    height: 16px;
    transform: translateX(50%);
    border-top: 2px solid var(--menu-accent);
    border-radius: 50% 50% 0 0 / 65% 65% 0 0;
    content: "";
}

.floating-indicator.is-moving::before {
    animation: floating-dot-spring .48s cubic-bezier(.22, 1, .36, 1);
}

.floating-menu :where(a, summary):focus-visible {
    outline: 2px solid var(--menu-accent);
    outline-offset: 3px;
}

@keyframes floating-menu-enter {
    from { opacity: 0; transform: translate(50%, 8px) scale(.98); }
    to { opacity: 1; transform: translate(50%, 0) scale(1); }
}

@keyframes floating-dot-spring {
    0%, 100% { transform: translateX(-50%) scale(1); }
    45% { transform: translateX(-50%) scale(1.12, .92); }
    75% { transform: translateX(-50%) scale(.98, 1.02); }
}

@media (max-width: 420px) {
    .floating-menu {
        bottom: calc(10px + env(safe-area-inset-bottom));
        width: calc(100vw - 20px);
        padding: 6px;
    }

    .floating-link {
        min-height: 56px;
        gap: 3px;
    }

    .floating-link svg {
        width: 18px;
        height: 18px;
    }

    .floating-link small {
        font-size: 9px;
    }

    .floating-indicator {
        left: 6px;
        width: calc((100% - 12px) / 4);
    }
}

@media (prefers-reduced-motion: reduce) {
    .floating-link,
    .floating-link svg,
    .floating-mega-menu a,
    .floating-indicator {
        transition: none;
    }

    .floating-mega-menu,
    .floating-indicator.is-moving::before {
        animation: none;
    }
}
