/* Site navbar alignment: hamburger + logo attached in one row */
.layout-topbar.layout-topbar-site {
    grid-template-columns: minmax(0, 1fr);
}

/* Obsidian Purple mobile/global navigation finish */
.layout-topbar.layout-topbar-site .left-nav {
    gap: 0.75rem;
}

.layout-topbar.layout-topbar-site .left-nav .nav-control-dock {
    margin-right: 0;
}

body.is-scrolled .nav-shell,
body.is-scrolled .app-topbar {
    border-color: rgba(139, 92, 246, 0.18);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

html[data-theme='light'] body.is-scrolled .nav-shell,
html[data-theme='light'] body.is-scrolled .app-topbar {
    box-shadow: 0 18px 40px rgba(17, 24, 39, 0.08);
}

@media (min-width: 1025px) {
    .layout-topbar.layout-topbar-site .left-nav .nav-control-dock,
    body.login-fix .layout-topbar.layout-topbar-site .left-nav .nav-control-dock,
    body.login-nav-fix .layout-topbar.layout-topbar-site .left-nav .nav-control-dock {
        background:
            linear-gradient(180deg, rgba(139, 92, 246, 0.14), rgba(5, 7, 15, 0.92)),
            var(--bg-secondary);
        border-color: var(--border);
        box-shadow: 0 14px 32px rgba(0, 0, 0, 0.24);
    }

    html[data-theme='light'] .layout-topbar.layout-topbar-site .left-nav .nav-control-dock,
    html[data-theme='light'] body.login-fix .layout-topbar.layout-topbar-site .left-nav .nav-control-dock,
    html[data-theme='light'] body.login-nav-fix .layout-topbar.layout-topbar-site .left-nav .nav-control-dock {
        background:
            linear-gradient(180deg, rgba(124, 58, 237, 0.1), rgba(255, 255, 255, 0.92)),
            var(--surface);
        box-shadow: 0 14px 32px rgba(17, 24, 39, 0.08);
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav {
        border-color: var(--border);
        border-radius: 16px;
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
            var(--surface-glow),
            var(--bg-elevated);
        box-shadow: var(--shadow-soft);
    }
}

@media (max-width: 1024px) {
    .sidebar {
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
            var(--bg-elevated);
        border-right: 1px solid var(--border);
        border-radius: 0 16px 16px 0;
    }

    .site-nav {
        border-radius: 16px;
        border-color: var(--border);
        background:
            linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012)),
            var(--surface-glow),
            var(--bg-elevated);
    }

    .site-nav a {
        border-radius: 12px;
    }
}

.layout-topbar.layout-topbar-site::after {
    display: none;
}

.layout-topbar.layout-topbar-site .nav-shell {
    grid-column: 1;
}

.layout-topbar.layout-topbar-site .nav-shell-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.layout-topbar.layout-topbar-site .topbar-slot-start {
    display: none;
}

.layout-topbar.layout-topbar-site .topbar-slot-center {
    justify-self: start;
    justify-content: flex-start;
    flex: 1 1 auto;
}

.layout-topbar.layout-topbar-site .topbar-slot-end {
    width: auto;
}

.layout-topbar.layout-topbar-site .left-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.layout-topbar.layout-topbar-site .left-nav .nav-control-dock {
    position: relative;
    margin-right: 12px;
    z-index: 1001;
    left: auto;
    top: auto;
    flex: 0 0 auto;
}

.layout-topbar.layout-topbar-site .left-nav .hamburger {
    position: relative;
    margin-right: 0;
    z-index: 1001;
}

.layout-topbar.layout-topbar-site .left-nav .brand {
    justify-content: flex-start;
}

body.login-nav-compact .nav-links {
    display: none !important;
}

@media (min-width: 1025px) {
    .layout-topbar.layout-topbar-site .left-nav .nav-control-dock {
        position: relative !important;
        left: auto !important;
        top: auto !important;
        isolation: auto;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .nav-shell-main {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .topbar-slot-start,
    body.login-nav-compact .layout-topbar.layout-topbar-site .topbar-slot-end {
        display: none !important;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .topbar-slot-center {
        justify-self: start;
        justify-content: flex-start;
        width: 100%;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .brand {
        justify-content: flex-start;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav-toggle {
        display: inline-flex !important;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav {
        position: sticky;
        top: 0;
        left: auto;
        width: min(280px, calc(100vw - 2rem));
        max-width: 280px;
        max-height: calc(100vh - 6.8rem);
        min-height: 0;
        padding: 1rem;
        border-radius: 24px;
        border: 1px solid var(--line);
        background: var(--surface-glow), var(--bg-elevated);
        box-shadow: 0 22px 42px rgba(5, 10, 28, 0.28);
        overflow-y: auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
        z-index: 1440;
        display: none !important;
    }

    body.login-nav-compact:not(.site-nav-collapsed) .layout-topbar.layout-topbar-site .site-nav {
        display: flex !important;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav .site-nav-group {
        display: grid;
        width: 100%;
        gap: 0.62rem;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav .site-nav-footer {
        display: grid;
        width: 100%;
        margin-top: auto;
        padding-top: 0.85rem;
        border-top: 1px solid var(--line);
        gap: 0.72rem;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav a,
    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav .theme-toggle,
    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav .button {
        width: 100%;
        justify-content: flex-start;
    }
}

body.login-fix .layout-topbar.layout-topbar-site .nav-shell-main,
body.login-nav-fix .layout-topbar.layout-topbar-site .nav-shell-main {
    display: flex;
    align-items: center;
}

body.login-fix .layout-topbar.layout-topbar-site .left-nav,
body.login-nav-fix .layout-topbar.layout-topbar-site .left-nav {
    display: flex;
    align-items: center;
    gap: 10px;
}

@media (min-width: 1025px) {
    body.login-fix .layout-topbar.layout-topbar-site .left-nav .nav-control-dock,
    body.login-nav-fix .layout-topbar.layout-topbar-site .left-nav .nav-control-dock {
        position: sticky !important;
        top: 0;
        left: auto;
        margin-right: 0;
        z-index: 1000;
    }

    body.login-fix .layout-topbar.layout-topbar-site .site-nav,
    body.login-nav-fix .layout-topbar.layout-topbar-site .site-nav {
        left: clamp(0.8rem, 1.2vw, 1.2rem);
        width: min(320px, calc(100vw - 2rem));
        max-width: 320px;
        max-height: calc(100vh - 6.8rem);
        overflow-y: auto;
        overflow-wrap: anywhere;
        word-break: break-word;
        backdrop-filter: blur(22px);
        -webkit-backdrop-filter: blur(22px);
    }
}

@media (max-width: 1024px) {
    body.login-nav-compact .layout-topbar.layout-topbar-site .nav-shell-main {
        display: flex;
        align-items: center;
        justify-content: space-between;
        text-align: left;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .topbar-slot-start,
    body.login-nav-compact .layout-topbar.layout-topbar-site .topbar-slot-end {
        display: none !important;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .topbar-slot-center {
        justify-self: start;
        justify-content: flex-start;
        width: 100%;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .brand {
        justify-content: flex-start;
    }

    body.login-nav-compact .layout-topbar.layout-topbar-site .site-nav-toggle {
        display: inline-flex !important;
    }

    .layout-topbar {
        gap: 0.75rem;
        position: relative;
        top: auto;
        z-index: 1410;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: start;
    }

    .layout-topbar::after {
        display: none;
    }

    .layout-topbar.layout-topbar-app,
    .layout-topbar.layout-topbar-site {
        max-width: none;
    }

    .layout-topbar.layout-topbar-app .app-topbar {
        grid-template-columns: 1fr;
        justify-items: center;
        text-align: center;
        min-height: 58px;
    }

    .layout-topbar.layout-topbar-app .app-topbar .topbar-slot-end {
        display: flex;
    }

    .layout-topbar.layout-topbar-app .topbar-slot-center {
        justify-self: center;
        justify-content: center;
        width: auto;
        min-width: 0;
    }

    .layout-topbar.layout-topbar-app .app-topbar.app-topbar-brand-left {
        grid-template-columns: auto minmax(0, 1fr);
        justify-items: stretch;
        text-align: left;
    }

    .layout-topbar.layout-topbar-app .app-topbar.app-topbar-brand-left .topbar-slot-start {
        display: flex;
        min-height: auto;
    }

    .layout-topbar.layout-topbar-app .app-topbar.app-topbar-brand-left .topbar-slot-center {
        display: none;
    }

    .layout-topbar.layout-topbar-app .topbar-slot-end .notification-label,
    .layout-topbar.layout-topbar-app .topbar-slot-end .theme-toggle > span:not(.theme-toggle-icon),
    .layout-topbar.layout-topbar-app .topbar-slot-end .theme-toggle strong {
        display: none;
    }

    .layout-topbar.layout-topbar-app .topbar-slot-end .notification-toggle,
    .layout-topbar.layout-topbar-app .topbar-slot-end .theme-toggle {
        min-width: 44px;
        width: 44px;
        height: 44px;
        padding: 0;
        gap: 0;
        justify-content: center;
        border-radius: 15px;
    }

    .layout-topbar.layout-topbar-app .topbar-slot-end .notification-toggle {
        position: relative;
    }

    .layout-topbar.layout-topbar-app .topbar-slot-end .notification-badge {
        position: absolute;
        top: -0.2rem;
        right: -0.18rem;
    }

    .nav-control-dock {
        width: 58px;
        min-width: 58px;
        height: 58px;
        padding: 0.3rem;
        border-radius: 20px;
    }

    .nav-shell,
    .app-topbar {
        padding: 0.9rem 0.95rem;
    }

    .nav-shell-main,
    .app-topbar {
        grid-template-columns: 1fr;
        align-items: center;
        justify-items: center;
        text-align: center;
        gap: 0.75rem;
    }

    .topbar-slot-start {
        display: none;
    }

    .topbar-slot-center {
        justify-self: center;
        justify-content: center;
    }

    .layout-topbar.layout-topbar-site .topbar-slot-end {
        display: none !important;
    }

    .app-topbar .brand-badge,
    .nav-shell .brand-badge {
        min-width: 4.25rem;
        height: 2.85rem;
        border-radius: 0.85rem;
    }

    .app-topbar .brand-badge-word,
    .nav-shell .brand-badge-word {
        font-size: 1.38rem;
    }

    .topbar-slot-end,
    .nav-actions,
    .topbar-actions {
        width: auto;
        justify-content: flex-end;
        flex-wrap: nowrap;
        gap: 0.65rem;
    }

    .sidebar {
        position: sticky;
        top: 0;
        left: 0.85rem;
        height: calc(100dvh - 1.7rem);
        width: min(84vw, 340px);
        max-width: 360px;
        transform: translateX(-100%);
        z-index: 1000;
        min-height: 0;
        padding: 1rem;
        overflow-y: auto;
        box-shadow: var(--shadow-soft);
        background: var(--bg-elevated);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        pointer-events: auto;
        opacity: 0;
        visibility: hidden;
        border-radius: 24px;
        display: grid;
        grid-template-rows: auto minmax(0, 1fr) auto;
        justify-content: stretch;
        align-content: stretch;
        gap: 1rem;
        isolation: isolate;
    }

    .sidebar.is-open,
    .sidebar.active,
    body.nav-open .sidebar {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    body.nav-open .layout-topbar.layout-topbar-app .app-topbar {
        opacity: 0;
        pointer-events: none;
        transform: translateY(-0.35rem);
    }

    .sidebar > .brand {
        justify-content: flex-start;
        margin-bottom: 0.1rem;
    }

    .sidebar-nav {
        align-content: start;
        display: grid;
        gap: 0.75rem;
        overflow-y: auto;
        padding-right: 0.2rem;
    }

    .sidebar-footer {
        display: grid;
        gap: 0.8rem;
        padding-top: 0.9rem;
        border-top: 1px solid var(--line);
        background: transparent;
    }

    .sidebar .nav-link,
    .sidebar .notification-toggle,
    .sidebar .theme-toggle,
    .sidebar .ghost-link {
        width: 100%;
        justify-content: flex-start;
    }

    .sidebar .nav-link {
        min-height: 3rem;
    }

    .sidebar .nav-profile-thumb {
        justify-self: start;
    }

    .sidebar .user-chip {
        gap: 0.6rem;
    }

    body.nav-open {
        overflow-x: hidden;
        overflow-y: auto;
    }

    .site-header {
        z-index: 1404;
    }

    .nav-shell,
    .footer-shell,
    .page-intro,
    .cta-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .site-nav {
        display: none;
        flex-direction: column;
        background: var(--surface-glow), var(--bg-elevated);
        padding: 0.75rem 0.5rem;
        width: 100%;
        border-radius: var(--radius-md);
        border: 1px solid var(--line);
        position: relative;
        z-index: 1406;
        transform: translateY(-0.75rem);
        opacity: 0;
        pointer-events: none;
    }

    .site-nav.is-open,
    .site-nav.active {
        display: flex;
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .notification-toggle,
    .theme-toggle {
        min-width: 0;
    }

    .notification-label {
        display: none;
    }

    .theme-toggle > span:not(.theme-toggle-icon),
    .theme-toggle strong {
        font-size: 0.84rem;
    }

    .site-nav a {
        width: 100%;
        padding: 0.65rem 0.75rem;
        border-radius: 12px;
    }

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

@media (max-width: 1180px) {
    .site-header {
        padding: 0.75rem 0.9rem 0;
    }

    .layout-topbar.layout-topbar-app,
    .layout-topbar.layout-topbar-site {
        margin-top: 0;
        padding-inline: 0;
    }

    body.nav-open,
    body.notification-open {
        overflow-x: hidden;
        overflow-y: hidden;
    }

    .nav-overlay {
        background: rgba(4, 7, 18, 0.74);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    body.nav-open .site-header,
    body.nav-open .app-shell,
    body.nav-open .flash-stack {
        z-index: 1005;
    }

    body.nav-open .app-shell > :not(.sidebar),
    body.nav-open .site-main,
    body.nav-open .site-footer {
        pointer-events: none;
    }

    body.nav-open .sidebar,
    body.nav-open .layout-topbar,
    body.nav-open .nav-control-dock,
    body.nav-open .nav-toggle,
    body.nav-open .site-nav {
        pointer-events: auto;
    }

    .layout-topbar {
        gap: 0.55rem;
        grid-template-columns: auto minmax(0, 1fr);
        align-items: center;
    }

    .nav-control-dock {
        width: 48px;
        min-width: 48px;
        height: 48px;
        padding: 0.18rem;
        border-radius: 16px;
    }

    .nav-toggle {
        width: 40px;
        height: 40px;
        padding: 0.62rem;
        gap: 4px;
        border-radius: 13px;
    }

    .nav-toggle span {
        max-width: 0.96rem;
    }

    .nav-toggle span:nth-child(2) {
        max-width: 0.76rem;
    }

    .nav-shell,
    .app-topbar {
        min-height: 48px;
        padding: 0.65rem 0.78rem;
        gap: 0.55rem;
    }

    .layout-topbar.layout-topbar-app .app-topbar {
        min-height: 48px;
        padding: 0.65rem 0.78rem;
    }

    .nav-shell-main,
    .app-topbar {
        gap: 0.55rem;
    }

    .app-topbar .brand-badge,
    .nav-shell .brand-badge {
        min-width: 3.7rem;
        height: 2.3rem;
        border-radius: 0.72rem;
        box-shadow: 0 8px 18px rgba(5, 10, 44, 0.22);
    }

    .app-topbar .brand-badge-word,
    .nav-shell .brand-badge-word {
        font-size: 1.12rem;
    }

    .topbar-slot-end,
    .nav-actions,
    .topbar-actions {
        gap: 0.42rem;
    }

    .layout-topbar.layout-topbar-app .topbar-slot-end .notification-toggle,
    .layout-topbar.layout-topbar-app .topbar-slot-end .theme-toggle {
        min-width: 38px;
        width: 38px;
        height: 38px;
        border-radius: 13px;
    }

    .notification-toggle,
    .theme-toggle {
        min-width: 0;
        padding: 0.5rem 0.62rem;
        gap: 0.42rem;
        font-size: 0.8rem;
    }

    .notification-bell,
    .theme-toggle-icon {
        transform: none;
    }

    .notification-bell {
        width: 0.82rem;
        height: 0.88rem;
    }

    .notification-badge {
        min-width: 1.15rem;
        height: 1.15rem;
        padding: 0 0.25rem;
        font-size: 0.68rem;
    }

    .theme-toggle-icon {
        width: 0.8rem;
        height: 0.8rem;
    }

    .theme-toggle > span:not(.theme-toggle-icon) {
        display: none;
    }

    .theme-toggle strong {
        font-size: 0.76rem;
        line-height: 1;
    }

    .sidebar {
        top: 0.7rem;
        left: 0.7rem;
        right: 0.7rem;
        width: auto;
        max-width: none;
        height: calc(100dvh - 1.4rem);
        padding: 0.95rem;
        gap: 0.85rem;
        border-radius: 20px;
        background: linear-gradient(180deg, rgba(17, 24, 54, 0.98), rgba(7, 11, 28, 0.985));
        border-color: rgba(126, 153, 255, 0.18);
        box-shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
        z-index: 1007;
    }

    .sidebar > .brand .brand-badge {
        min-width: 4rem;
        height: 2.6rem;
        border-radius: 0.78rem;
        box-shadow:
            inset 0 1px 0 rgba(255, 255, 255, 0.07),
            0 10px 20px rgba(5, 10, 44, 0.14);
    }

    .sidebar > .brand .brand-badge-word {
        font-size: 1.2rem;
    }

    .sidebar-nav {
        gap: 0.62rem;
        padding-right: 0;
    }

    .sidebar .nav-link {
        min-height: 2.7rem;
        padding: 0.72rem 0.82rem;
        font-size: 0.94rem;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.02);
    }

    .sidebar .notification-toggle,
    .sidebar .theme-toggle {
        padding: 0.62rem 0.78rem;
        font-size: 0.84rem;
        border-radius: 14px;
    }

    .sidebar .nav-profile-thumb {
        width: 2.35rem;
        height: 2.35rem;
    }

    .sidebar .user-chip-meta strong,
    .sidebar .user-chip-meta small,
    .sidebar .ghost-link {
        font-size: 0.84rem;
    }

    .sidebar-footer {
        margin-top: auto;
        padding-top: 0.8rem;
    }

    .notification-popover {
        position: fixed;
        top: 0.8rem;
        left: 0.7rem;
        right: 0.7rem;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - 1.4rem);
        overflow: hidden;
    }

    .notification-popover-list {
        max-height: calc(100dvh - 8rem);
    }

    .notification-drawer {
        top: auto;
        bottom: 0;
        width: 100%;
        height: calc(100dvh - 4.4rem);
        max-height: calc(100dvh - 4.4rem);
        border-left: 0;
        border-top: 1px solid var(--line-strong);
        border-radius: 24px 24px 0 0;
    }

    .site-nav {
        position: sticky;
        top: 0;
        left: 0.7rem;
        right: 0.7rem;
        width: auto;
        max-width: none;
        max-height: calc(100dvh - 1.4rem);
        min-height: calc(100dvh - 1.4rem);
        padding: 4.25rem 0.95rem 0.95rem;
        gap: 0.62rem;
        border-radius: 20px;
        background: linear-gradient(180deg, rgba(17, 24, 54, 0.98), rgba(7, 11, 28, 0.985));
        border-color: rgba(126, 153, 255, 0.18);
        box-shadow: 0 24px 56px rgba(0, 0, 0, 0.42);
        transform: translateX(-1rem);
        opacity: 0;
        pointer-events: none;
        overflow-y: auto;
        z-index: 1007;
    }

    .site-nav-group {
        display: grid;
        gap: 0.62rem;
        width: 100%;
    }

    .site-nav.site-nav-authenticated .site-nav-group-public {
        display: none;
    }

    .site-nav.site-nav-authenticated .site-nav-group-workspace,
    .site-nav.site-nav-guest .site-nav-group-public {
        display: grid;
    }

    .site-nav.site-nav-guest .site-nav-group-workspace {
        display: none;
    }

    .site-nav.is-open,
    .site-nav.active {
        display: flex;
        transform: translateX(0);
        opacity: 1;
        pointer-events: auto;
    }

    .site-nav a {
        min-height: 2.7rem;
        padding: 0.72rem 0.82rem;
        font-size: 0.94rem;
        border-radius: 14px;
        background: rgba(255, 255, 255, 0.02);
    }

    .site-nav-footer {
        width: 100%;
        margin-top: auto;
        padding-top: 0.8rem;
        border-top: 1px solid var(--line);
        gap: 0.75rem;
    }

    .site-nav.site-nav-authenticated .site-nav-footer-authenticated,
    .site-nav.site-nav-guest .site-nav-footer-guest {
        display: grid;
    }

    .site-nav.site-nav-authenticated .site-nav-footer-guest,
    .site-nav.site-nav-guest .site-nav-footer-authenticated {
        display: none;
    }

    .site-nav .notification-toggle,
    .site-nav .theme-toggle,
    .site-nav .ghost-link {
        width: 100%;
        justify-content: flex-start;
    }

    .site-nav .nav-profile-thumb {
        justify-self: start;
    }

    .site-nav .user-chip {
        gap: 0.6rem;
    }

    .site-nav .user-chip-meta strong,
    .site-nav .user-chip-meta small,
    .site-nav .ghost-link {
        font-size: 0.84rem;
    }
}

@media (max-width: 480px) {
    .site-header {
        padding: 0.65rem 0.7rem 0;
    }

    .layout-topbar {
        gap: 0.45rem;
    }

    .nav-control-dock {
        width: 44px;
        min-width: 44px;
        height: 44px;
        border-radius: 15px;
    }

    .nav-toggle {
        width: 36px;
        height: 36px;
        padding: 0.55rem;
        border-radius: 12px;
    }

    .nav-shell,
    .app-topbar {
        min-height: 44px;
        padding: 0.58rem 0.68rem;
    }

    .layout-topbar.layout-topbar-app .topbar-slot-end .notification-toggle,
    .layout-topbar.layout-topbar-app .topbar-slot-end .theme-toggle {
        min-width: 34px;
        width: 34px;
        height: 34px;
        border-radius: 11px;
    }

    .app-topbar .brand-badge,
    .nav-shell .brand-badge {
        min-width: 3.3rem;
        height: 2.05rem;
        border-radius: 0.68rem;
    }

    .app-topbar .brand-badge-word,
    .nav-shell .brand-badge-word {
        font-size: 0.98rem;
    }

    .sidebar {
        top: 0.55rem;
        left: 0.55rem;
        right: 0.55rem;
        width: calc(100vw - 1.1rem);
        max-width: none;
        height: calc(100dvh - 1.1rem);
        padding: 0.8rem;
    }

    .sidebar > .brand .brand-badge {
        min-width: 3.65rem;
        height: 2.35rem;
    }

    .sidebar > .brand .brand-badge-word {
        font-size: 1.08rem;
    }

    .sidebar .nav-link,
    .sidebar .notification-toggle,
    .sidebar .theme-toggle {
        font-size: 0.82rem;
    }

    .site-nav {
        top: 0.55rem;
        left: 0.55rem;
        right: 0.55rem;
        min-height: calc(100dvh - 1.1rem);
        max-height: calc(100dvh - 1.1rem);
        padding: 3.9rem 0.8rem 0.8rem;
    }

    .site-nav a {
        font-size: 0.82rem;
    }

    .site-nav .notification-toggle,
    .site-nav .theme-toggle,
    .site-nav .ghost-link {
        font-size: 0.82rem;
    }
}

/* Final navigation overrides after legacy mobile sizing */
.layout-topbar.layout-topbar-site .left-nav {
    gap: 0.75rem;
}

.layout-topbar.layout-topbar-site .left-nav .nav-control-dock {
    margin-right: 0;
}

.app-topbar .brand-badge,
.nav-shell .brand-badge,
.sidebar > .brand .brand-badge {
    min-width: auto;
    height: auto;
    padding: 0;
    border-radius: 0;
}

.app-topbar .brand-badge-word,
.nav-shell .brand-badge-word,
.sidebar > .brand .brand-badge-word {
    font-size: 1.08rem;
}

/* ==========================================================================
   Unified Top Navbar Override
   Replaces hamburger/sidebar navigation with a persistent topbar while keeping
   existing routes, classes, and JS targets intact.
   ========================================================================== */

body.has-unified-topbar {
    --unified-topbar-clearance: clamp(6rem, 8vw, 6.75rem);
}

body.has-unified-topbar .site-header {
    position: sticky;
    top: 0;
    z-index: 1600;
    padding: 1rem clamp(0.9rem, 2vw, 1.5rem) 0;
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.82), rgba(0, 0, 0, 0.5) 72%, rgba(0, 0, 0, 0));
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    isolation: isolate;
}

body.has-unified-topbar .layout-topbar,
body.has-unified-topbar .layout-topbar.layout-topbar-site,
body.has-unified-topbar .layout-topbar.layout-topbar-unified {
    max-width: 1400px;
    margin: 0 auto;
    display: block;
}

body.has-unified-topbar .layout-topbar::after,
body.has-unified-topbar .nav-control-dock,
body.has-unified-topbar .nav-toggle,
body.has-unified-topbar .site-nav-toggle,
body.has-unified-topbar .hamburger,
body.has-unified-topbar [data-app-sidebar] {
    display: none !important;
}

body.has-unified-topbar .nav-shell {
    width: 100%;
    margin: 0;
    padding: 0.85rem 1.1rem;
    border-radius: 26px;
    border: 1px solid rgba(139, 92, 246, 0.22);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.012)),
        radial-gradient(circle at top right, rgba(139, 92, 246, 0.16), transparent 26%),
        rgba(5, 7, 15, 0.72);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 22px 48px rgba(0, 0, 0, 0.32),
        0 0 36px rgba(139, 92, 246, 0.14);
    backdrop-filter: blur(22px) saturate(1.06);
    -webkit-backdrop-filter: blur(22px) saturate(1.06);
}

html[data-theme='light'] body.has-unified-topbar .nav-shell {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.84), rgba(255, 255, 255, 0.7)),
        radial-gradient(circle at top right, rgba(124, 58, 237, 0.1), transparent 26%),
        rgba(255, 255, 255, 0.78);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.78),
        0 20px 44px rgba(17, 24, 39, 0.1);
}

body.has-unified-topbar .nav-shell-main.nav-shell-main-unified {
    display: grid;
    grid-template-columns: minmax(112px, auto) minmax(0, 1fr) auto;
    align-items: center;
    gap: 1.1rem;
}

body.has-unified-topbar .topbar-slot {
    min-width: 0;
}

body.has-unified-topbar .topbar-slot-start {
    display: flex !important;
    justify-content: flex-start;
}

body.has-unified-topbar .topbar-slot-end {
    display: flex !important;
    justify-self: end;
    justify-content: flex-end;
    width: auto;
}

body.has-unified-topbar .brand {
    justify-content: flex-start;
}

body.has-unified-topbar .site-nav,
body.has-unified-topbar .site-nav.is-open,
body.has-unified-topbar .site-nav.active {
    position: static !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 0 !important;
    max-height: none !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    opacity: 1 !important;
    transform: none !important;
    pointer-events: auto !important;
    overflow: visible;
}

body.has-unified-topbar .site-nav-inline {
    min-width: 0;
}

body.has-unified-topbar .site-nav-group,
body.has-unified-topbar .site-nav-group-public,
body.has-unified-topbar .site-nav-group-workspace {
    display: flex !important;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.45rem;
    width: 100%;
}

body.has-unified-topbar .site-nav a,
body.has-unified-topbar .nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0.72rem 1rem;
    border-radius: 999px;
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    background: transparent;
    white-space: nowrap;
}

body.has-unified-topbar .site-nav a:hover,
body.has-unified-topbar .site-nav a.is-active,
body.has-unified-topbar .nav-link:hover,
body.has-unified-topbar .nav-link.is-active {
    color: var(--text);
    border-color: rgba(139, 92, 246, 0.28);
    background: rgba(139, 92, 246, 0.12);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        0 10px 22px rgba(139, 92, 246, 0.12);
}

body.has-unified-topbar .nav-actions-unified {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.7rem;
    flex-wrap: nowrap;
}

body.has-unified-topbar .notification-toggle,
body.has-unified-topbar .theme-toggle,
body.has-unified-topbar .user-menu-toggle {
    min-width: 46px;
    height: 46px;
    padding: 0.68rem 0.9rem;
    border-radius: 14px;
    border: 1px solid rgba(139, 92, 246, 0.18);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

body.has-unified-topbar .notification-toggle,
body.has-unified-topbar .theme-toggle {
    width: 46px;
    justify-content: center;
}

body.has-unified-topbar .notification-label,
body.has-unified-topbar .theme-toggle-copy,
body.has-unified-topbar .theme-toggle strong {
    display: none;
}

body.has-unified-topbar .notification-toggle:hover,
body.has-unified-topbar .notification-toggle[aria-expanded='true'],
body.has-unified-topbar .theme-toggle:hover,
body.has-unified-topbar .user-menu.is-open .user-menu-toggle,
body.has-unified-topbar .user-menu-toggle:hover {
    border-color: rgba(139, 92, 246, 0.34);
    background: rgba(139, 92, 246, 0.14);
    box-shadow: 0 14px 28px rgba(139, 92, 246, 0.16);
    transform: translateY(-1px);
}

body.has-unified-topbar .notification-toggle {
    position: relative;
}

body.has-unified-topbar .notification-badge {
    position: absolute;
    top: -0.28rem;
    right: -0.2rem;
    min-width: 1.28rem;
    height: 1.28rem;
    font-size: 0.72rem;
    box-shadow: 0 8px 18px rgba(139, 92, 246, 0.32);
}

body.has-unified-topbar .user-menu {
    position: relative;
}

body.has-unified-topbar .user-menu-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    width: auto;
    min-width: 8.85rem;
    padding-right: 0.82rem;
}

body.has-unified-topbar .user-menu-copy {
    display: grid;
    gap: 0.05rem;
    text-align: left;
    min-width: 0;
}

body.has-unified-topbar .user-menu-copy strong {
    font-size: 0.9rem;
    line-height: 1.05;
    white-space: nowrap;
}

body.has-unified-topbar .user-menu-copy small {
    color: var(--text-soft);
    font-size: 0.68rem;
    letter-spacing: 0.08em;
}

body.has-unified-topbar .user-menu-caret {
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-1px);
    color: var(--text-soft);
    transition: transform 0.2s ease;
}

body.has-unified-topbar .user-menu.is-open .user-menu-caret {
    transform: rotate(225deg) translateY(-1px);
}

body.has-unified-topbar .user-menu-panel {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    min-width: 220px;
    padding: 0.5rem;
    border-radius: 18px;
    border: 1px solid rgba(139, 92, 246, 0.18);
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)),
        rgba(8, 10, 20, 0.96);
    box-shadow:
        0 18px 40px rgba(0, 0, 0, 0.32),
        0 0 28px rgba(139, 92, 246, 0.12);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 1605;
}

html[data-theme='light'] body.has-unified-topbar .user-menu-panel {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(255, 255, 255, 0.88)),
        rgba(255, 255, 255, 0.92);
}

body.has-unified-topbar .user-menu-link {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 42px;
    padding: 0.78rem 0.9rem;
    border-radius: 14px;
    color: var(--text);
    font-weight: 500;
}

body.has-unified-topbar .user-menu-link:hover {
    background: rgba(139, 92, 246, 0.14);
    color: var(--text);
}

body.has-unified-topbar .user-menu-link-logout {
    color: #f7c3d2;
}

body.has-unified-topbar .user-menu-link-logout:hover {
    color: var(--text);
    background: rgba(255, 107, 148, 0.18);
}

body.has-unified-topbar .nav-profile-thumb {
    width: 34px;
    height: 34px;
    border-radius: 11px;
    flex: 0 0 auto;
}

body.has-unified-topbar .nav-avatar-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 0.86rem;
    font-weight: 700;
    color: #eef2ff;
}

body.has-unified-topbar .auto-refresh {
    left: 1rem;
}

@media (max-width: 1180px) {
    body.has-unified-topbar .nav-shell-main.nav-shell-main-unified {
        grid-template-columns: auto auto;
    }

    body.has-unified-topbar .site-nav,
    body.has-unified-topbar .site-nav.is-open,
    body.has-unified-topbar .site-nav.active {
        grid-column: 1 / -1;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 0.15rem !important;
        scrollbar-width: none;
    }

    body.has-unified-topbar .site-nav::-webkit-scrollbar {
        display: none;
    }

    body.has-unified-topbar .site-nav-group,
    body.has-unified-topbar .site-nav-group-public,
    body.has-unified-topbar .site-nav-group-workspace {
        width: max-content;
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
}

@media (max-width: 820px) {
    body.has-unified-topbar .nav-shell {
        padding: 0.78rem 0.85rem;
        border-radius: 22px;
    }

    body.has-unified-topbar .nav-actions-unified {
        gap: 0.55rem;
    }

    body.has-unified-topbar .notification-toggle,
    body.has-unified-topbar .theme-toggle,
    body.has-unified-topbar .user-menu-toggle {
        height: 42px;
    }

    body.has-unified-topbar .user-menu-copy {
        display: none;
    }

    body.has-unified-topbar .user-menu-toggle {
        min-width: 46px;
        padding-right: 0.9rem;
    }

    body.has-unified-topbar .site-nav a,
    body.has-unified-topbar .nav-link {
        min-height: 40px;
        padding: 0.66rem 0.86rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 640px) {
    body.has-unified-topbar .site-header {
        padding: 0.75rem 0.75rem 0;
    }

    body.has-unified-topbar .nav-shell-main.nav-shell-main-unified {
        gap: 0.8rem;
    }

    body.has-unified-topbar .site-nav a,
    body.has-unified-topbar .nav-link {
        padding: 0.62rem 0.8rem;
        font-size: 0.86rem;
    }

    body.has-unified-topbar .user-menu-panel {
        right: -0.1rem;
        min-width: min(220px, calc(100vw - 1.8rem));
    }
}

/* Prevent compact unified navigation from widening the page on small screens. */
@media (max-width: 1180px) {
    html,
    body.has-unified-topbar {
        max-width: 100%;
        overflow-x: hidden;
    }

    body.has-unified-topbar .site-header,
    body.has-unified-topbar .layout-topbar,
    body.has-unified-topbar .nav-shell,
    body.has-unified-topbar .nav-shell-main.nav-shell-main-unified {
        max-width: 100%;
        min-width: 0;
    }

    body.has-unified-topbar .nav-shell {
        overflow: hidden;
    }

    body.has-unified-topbar .site-nav,
    body.has-unified-topbar .site-nav.site-nav-inline,
    body.has-unified-topbar .site-nav.is-open,
    body.has-unified-topbar .site-nav.active {
        min-width: 0;
        max-width: 100%;
        overflow-x: visible !important;
        overflow-y: visible !important;
    }

    body.has-unified-topbar .site-nav-group,
    body.has-unified-topbar .site-nav-group-public,
    body.has-unified-topbar .site-nav-group-workspace {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        flex-wrap: wrap;
        justify-content: center;
    }
}

@media (max-width: 820px) {
    body.has-unified-topbar .site-nav,
    body.has-unified-topbar .site-nav.site-nav-inline {
        overflow-x: visible !important;
    }

    body.has-unified-topbar .site-nav-group,
    body.has-unified-topbar .site-nav-group-public,
    body.has-unified-topbar .site-nav-group-workspace {
        width: 100%;
        min-width: 0;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.35rem;
    }

    body.has-unified-topbar .site-nav a,
    body.has-unified-topbar .nav-link {
        width: auto !important;
        flex: 0 1 auto;
        min-width: 0;
        min-height: 34px;
        padding: 0.5rem 0.56rem;
        font-size: 0.76rem;
    }
}

@media (max-width: 640px) {
    body.has-unified-topbar {
        --unified-topbar-clearance: clamp(10.5rem, 42vw, 12.5rem);
    }

    body.has-unified-topbar .nav-shell-main.nav-shell-main-unified {
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        gap: 0.6rem;
    }

    body.has-unified-topbar .topbar-slot-start,
    body.has-unified-topbar .topbar-slot-end,
    body.has-unified-topbar .site-nav,
    body.has-unified-topbar .site-nav.site-nav-inline {
        grid-column: 1;
        width: 100%;
    }

    body.has-unified-topbar .topbar-slot-start {
        justify-content: flex-start;
    }

    body.has-unified-topbar .topbar-slot-end {
        justify-self: stretch;
        justify-content: stretch;
    }

    body.has-unified-topbar .nav-actions-unified {
        width: 100%;
        justify-content: stretch;
        gap: 0.5rem;
    }

    body.has-unified-topbar .nav-actions-unified .button {
        flex: 1 1 0;
        min-width: 0;
        min-height: 36px;
        padding: 0.58rem 0.62rem;
        border-radius: 12px;
        font-size: 0.78rem;
    }

    body.has-unified-topbar .site-nav,
    body.has-unified-topbar .site-nav.site-nav-inline {
        overflow-x: visible !important;
    }

    body.has-unified-topbar .site-nav-group,
    body.has-unified-topbar .site-nav-group-public,
    body.has-unified-topbar .site-nav-group-workspace {
        width: 100%;
        min-width: 0;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.35rem;
    }

    body.has-unified-topbar .site-nav a,
    body.has-unified-topbar .nav-link {
        width: auto !important;
        flex: 0 1 auto;
        min-width: 0;
        min-height: 32px;
        padding: 0.46rem 0.48rem;
        font-size: 0.72rem;
    }
}

@media (max-width: 767px) {
    body.has-unified-topbar .site-nav-group,
    body.has-unified-topbar .site-nav-group-public,
    body.has-unified-topbar .site-nav-group-workspace {
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 0.32rem !important;
    }

    body.has-unified-topbar .site-nav a,
    body.has-unified-topbar .nav-link {
        flex: 0 1 auto !important;
        width: auto !important;
        min-width: 0 !important;
        min-height: 31px !important;
        padding: 0.42rem 0.44rem !important;
        font-size: 0.7rem !important;
    }
}

/* ==========================================================================
   Shared page wrapper layout lives in global.css.
   ========================================================================== */
