How to know whether you are editing a page or a post?

You can use the admin_body_class hook to add your own CSS classes. For example (if you’re using Gutenberg):

function pb_admin_body_class($classes) {
    $screen = get_current_screen();

    if (!$screen->is_block_editor()) {
        return $classes;
    }

    $post_id = isset($_GET['post']) ? intval($_GET['post']) : false;
    $post_type = get_post_type($post_id);

    if ($post_type) {
        $classes .= $post_type;
    }

    return $classes;
}
add_filter('admin_body_class', 'pb_admin_body_class');