/* Global topbar */
.nav-shell {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 60;
    height: 74px;
    pointer-events: none;
    box-sizing: border-box;
    padding: 0 max(12px, env(safe-area-inset-right, 0px)) 0 max(12px, env(safe-area-inset-left, 0px));
    overflow-x: clip;
    max-width: 100vw;
}

.command-nav {
    pointer-events: auto;
    width: 100%;
    max-width: 1120px;
    margin: 1px auto 0;
    min-width: 0;
    min-height: 60px;
    border-radius: 999px;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand menu actions";
    align-items: center;
    gap: 10px;
    padding: 0 12px 0 16px;
    background: rgba(8, 14, 28, .82);
    border: 1px solid rgba(255, 255, 255, .22);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .38), inset 0 1px 0 rgba(255, 255, 255, .08);
    backdrop-filter: blur(18px);
    box-sizing: border-box;
    overflow: hidden;
}

.command-nav .brand {
    grid-area: brand;
    display: flex;
    align-items: center;
    min-height: 40px;
    min-width: 0;
    flex-shrink: 0;
    text-decoration: none;
}

.command-nav .brand img {
    display: block;
    height: 40px;
    width: auto;
    max-width: min(140px, 36vw);
    object-fit: contain;
}

.nav-menu {
    grid-area: menu;
    display: flex;
    justify-content: center;
    align-items: stretch;
    min-width: 0;
    height: 58px;
    gap: 2px;
    overflow: hidden;
}

.nav-item {
    min-width: 0;
    flex: 1 1 0;
    max-width: 92px;
    height: 58px;
    border-radius: 22px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    position: relative;
    transition: .24s var(--ease);
    padding: 0 4px;
    text-align: center;
}

.nav-item svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.8;
    opacity: .92;
    flex: none;
}

.nav-item:hover,
.nav-item.active {
    color: var(--orange);
    background: linear-gradient(180deg, rgba(255, 255, 255, .12), rgba(255, 255, 255, .035));
}

.nav-actions {
    grid-area: actions;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex-shrink: 0;
}

.nav-btn {
    height: 38px;
    border-radius: 999px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, .12);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 800;
    background: rgba(255, 255, 255, .05);
    white-space: nowrap;
}

.nav-btn.primary {
    border: 0;
    background: linear-gradient(180deg, var(--orange2), var(--orange));
    box-shadow: 0 12px 28px rgba(255, 102, 0, .26);
}

.nav-toggle {
    grid-area: toggle;
    display: none;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 14px;
    background: rgba(255, 255, 255, .06);
    color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    flex-shrink: 0;
    transition: .24s var(--ease);
}

.nav-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
    transition: transform .24s var(--ease), opacity .24s var(--ease);
}

.nav-menu-actions {
    display: none;
}

.nav-shell {
    transition: opacity 0.45s ease;
}

html.is-hero-locked .nav-shell {
    opacity: 0;
    pointer-events: none;
}

body.nav-open {
    overflow: hidden;
}

/* Compact nav: class set in head before paint */
html.nav-compact .command-nav {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "brand toggle";
    gap: 10px;
    padding: 8px 10px 8px 14px;
    border-radius: 22px;
    max-width: 100%;
}

html.nav-compact .command-nav .brand img {
    height: 34px;
}

html.nav-compact .nav-toggle {
    display: inline-flex;
}

html.nav-compact .nav-actions {
    display: none !important;
}

html.nav-compact .nav-menu {
    position: fixed;
    top: calc(74px + 6px);
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    width: auto;
    max-width: calc(100vw - 24px);
    z-index: 80;
    height: auto;
    max-height: calc(100dvh - 96px);
    overflow-x: hidden;
    overflow-y: auto;
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 12px;
    border-radius: 22px;
    background: rgba(8, 14, 28, .96);
    border: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 24px 48px rgba(0, 0, 0, .42);
    backdrop-filter: blur(18px);
    display: none !important;
    pointer-events: none;
}

html.nav-compact .command-nav.is-open .nav-menu {
    display: flex !important;
    pointer-events: auto;
}

html.nav-compact .nav-item {
    flex: none;
    max-width: none;
    width: 100%;
    height: auto;
    min-height: 48px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 16px;
    font-size: 14px;
}

html.nav-compact .nav-menu-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 6px;
    padding-top: 10px;
    border-top: 1px solid rgba(255, 255, 255, .10);
}

html.nav-compact .nav-menu-actions .nav-btn {
    width: 100%;
    justify-content: center;
    height: 44px;
    font-size: 13px;
}

html.nav-compact .command-nav.is-open .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

html.nav-compact .command-nav.is-open .nav-toggle-bar:nth-child(2) {
    opacity: 0;
}

html.nav-compact .command-nav.is-open .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 1180px) {
    .command-nav {
        position: relative;
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas: "brand toggle";
        gap: 10px;
        padding: 8px 10px 8px 14px;
        border-radius: 22px;
        max-width: 100%;
    }

    .command-nav .brand img {
        height: 34px;
    }

    .nav-toggle {
        display: inline-flex;
    }

    .nav-actions {
        display: none !important;
    }

    .nav-menu {
        position: fixed;
        top: calc(74px + 6px);
        left: max(12px, env(safe-area-inset-left, 0px));
        right: max(12px, env(safe-area-inset-right, 0px));
        width: auto;
        max-width: calc(100vw - 24px);
        z-index: 80;
        height: auto;
        max-height: calc(100dvh - 96px);
        overflow-x: hidden;
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 12px;
        border-radius: 22px;
        background: rgba(8, 14, 28, .96);
        border: 1px solid rgba(255, 255, 255, .16);
        box-shadow: 0 24px 48px rgba(0, 0, 0, .42);
        backdrop-filter: blur(18px);
        display: none !important;
        pointer-events: none;
    }

    .command-nav.is-open .nav-menu {
        display: flex !important;
        pointer-events: auto;
    }

    .nav-item {
        flex: none;
        max-width: none;
        width: 100%;
        height: auto;
        min-height: 48px;
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        padding: 12px 14px;
        border-radius: 16px;
        font-size: 14px;
    }

    .nav-menu-actions {
        display: flex;
        flex-direction: column;
        gap: 10px;
        margin-top: 6px;
        padding-top: 10px;
        border-top: 1px solid rgba(255, 255, 255, .10);
    }

    .nav-menu-actions .nav-btn {
        width: 100%;
        justify-content: center;
        height: 44px;
        font-size: 13px;
    }

    .command-nav.is-open .nav-toggle-bar:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    .command-nav.is-open .nav-toggle-bar:nth-child(2) {
        opacity: 0;
    }

    .command-nav.is-open .nav-toggle-bar:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }
}

@media (max-width: 640px) {
    .nav-shell {
        padding-inline: max(8px, env(safe-area-inset-right, 0px)) max(8px, env(safe-area-inset-left, 0px));
    }

    .command-nav {
        padding: 8px 8px 8px 12px;
    }

    .nav-toggle {
        width: 40px;
        height: 40px;
    }
}
