Using Card-Mod on a Lovelace Gauge Card w/Segments

I have some gauge cards that use segments measuring various soil conditions for some plants. For example, if fertility/conductivity is below 350 or above 2200 the needle is in the red, if it’s between 350 and 550 or 2000 and 2200 the needle is in the yellow, and between 550 and 2000 it’s in the green.
I would like to have the card border go to the same colors, but I’m not sure how to do that.

Go easy on me, I’m really new to programming, both with YAML and CSS, and I’m not finding a lot online that shows how to handle this type of situation. The only “programming” I’ve done is working with a lot of formulas in Excel.

The code below is as close as I’ve gotten. No, it doesn’t work. And it’s entirely possible that I’m way off and going in the complete wrong direction. Does anyone know how to accomplish what I’m trying to do?

Thanks!

- type: gauge
    needle: true
    style: |
      :host {
        --ha-card-border-color: 
        {% set sensor = states('sensor.plant_sensor_3_conductivity') %}
        {% if sensor == | < 350 %}red 
        {% elif sensor == | < 550 %}yellow
        {% elif sensor == | < 2000 %}green
        {% elif sensor == | < 2200 %}yellow
        {% else %}red
        {% endif %};
       }
    min: 0
    max: 3000
    segments:
      - from: 0
        color: '#db4437'
      - from: 350
        color: '#ffa600'
      - from: 550
        color: '#43a047'
      - from: 2000
        color: '#ffa600'
      - from: 2200
        color: '#db4437'
    name: Fertility
    entity: sensor.plant_sensor_3_conductivity