@layer components {
  .grant-fields {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-block-start: 1rem;
  }

  .grant-fields__area {
    border: none;
    margin: 0;
    padding: 0;
  }

  .grant-fields__pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-block-start: 0.375rem;
  }

  .grant-fields__pill {
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-pill);
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.375rem 0.875rem;
  }

  /* The radio is off screen; the keyboard's focus shows on the pill. */
  .grant-fields__pill:has(input:focus-visible) {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
  }

  .grant-fields__pill:has(input:checked) {
    background: var(--color-brand-tint);
    border-color: var(--color-brand);
    color: var(--color-brand);
  }

  /* A predefined role's pills are read, not set: they keep their colour so
     the role's levels can be seen, and lose the hand cursor. */
  .grant-fields__area:disabled .grant-fields__pill {
    cursor: default;
  }

  .grant-fields__area:disabled .grant-fields__pill:not(:has(input:checked)) {
    color: var(--color-ink-muted);
  }
}
