<?php

/**
 * @file
 * Theme functions for My Theme.
 */

/**
 * Implements hook_page_attachments().
 *
 * Attaches the adminimal-custom.css only for admin pages.
 */
function my_theme_page_attachments(array &$attachments) {
  // Check if we're on an admin route.
  if (\Drupal::service('router.admin_context')->isAdminRoute()) {
    // Attach the admin-only CSS library.
    $attachments['#attached']['library'][] = 'my_theme/admin-only-styling';
  }
}