I have a Sass-driven site I’ve inherited. There’s a `variables.scss` file that defines a bunch of color and media size and other variables; makes sense. But now I want to basically overwrite all those variables with new values for dark-mode purposes. Is there a way to easily do this in Sass?

(Assume I have DDGed `sass dark mode` and none of the first dozen hits seemed to be relevant to this kind of situation, either because they aren’t or because I don’t speak Sassafrassh and so misunderstood.)

@Meyerweb completely contrived example (sorry ahead of time if this does not bear any relevance to your question, all depends on how the variables are being used, and how the project is toggling dark/light mode styling)
```
// variables that might be defined in your variables.scss file
$a_color: #dca;
$an_another_color: #753;

// some random stylesheet
.foo {
background: $a_background_color;
}
@media (prefers-color-scheme: dark) {
.foo {
background: $an_another_color;
}
}
```

@wholewheattoast So basically define dark-mode versions of all the colors, like so:
```
$main-color: #333;
$dark-main-color: #CCC;
$bg-color: #EEE;
$dark-bg-color: #111;
```
…and then flop everything in CSS `@media()` statements? That feels really clumsy, given that the `$color` references will be scattered throughout the rest of the Sass. I’d much rather something like:
```
$main-color: #333;
$bg-color: #EEE;

@media (prefers-color-scheme: dark) {
$main-color: #CCC;
$bg-color: #111;
}
```

@Meyerweb That won't work in Sass because it's precompiled, but you could switch them out for CSS custom properties.

```
--main-color: #333;
--bg-color: #EEE;

@media (prefers-color-scheme: dark) {
--main-color: #CCC;
--bg-color: #111;
}
```

Then just do a search and replace on the CSS for `$main-color` and replace it with `--var(--main-color)` etc.

@danbarber Yeah, this is the conclusion I’ve been coming to as I‘ve tried various ideas and run into deep quicksand. I’m a little unhappy about it given universal `var()` support only goes back about five years, so I’ll need to backstop all the var()s, but I guess nobody promised this would be easy.

Edited to addend: Huh, I guess it’s actually been eight years, not five. Time!… is marching on, and time… is still marching on.)

@Meyerweb The only other solution is (as someone already suggested) separate variables for dark values and media queries everywhere you need to change it. Better browser support but harder maintenance.