<html> HTML
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Theme Demo</title>
</head>
<body>
<!-- To test the manual override, change <html lang="en"> to <html class="theme-dark" lang="en">. -->
<div class="panel">
<h2>Theme Demo</h2>
<p>This panel and button read colors from CSS variables.</p>
<button class="btn" type="button" aria-label="Static themed button sample">Tokenized button</button>
</div>
</body>
</html># CSS
/* TASK
1) Define variables on :root (light defaults):
--bg, --text, --surface, --accent, --border, --accent-contrast, --panel-shadow
2) OS dark mode:
@media (prefers-color-scheme: dark) {
:root {
...same vars, dark values...
}
}
3) Manual override:
html.theme-dark {
...same vars, dark values...
}
IMPORTANT: place html.theme-dark AFTER the media query so it always wins.
Test it by editing the opening <html> tag in the HTML panel.
Constraint:
- .panel and .btn must use ONLY variables for colors and colored shadow values.
*/
/* Base page styles using variables (you will define them) */
html, body {
height: 100%;
}
body {
font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
margin: 0;
line-height: 1.6;
background: var(--bg);
color: var(--text);
display: grid;
place-items: center;
padding: 2rem;
}
.panel {
background: var(--surface);
color: var(--text);
border: 1px solid var(--border);
border-radius: 12px;
padding: 1.25rem;
box-shadow: var(--panel-shadow);
max-width: 520px;
}
.btn {
background: var(--accent);
color: var(--accent-contrast);
border: 0;
padding: .5rem .9rem;
border-radius: .6rem;
font-weight: 600;
}Live preview updates as you type
Building preview…