Skip to content

Commit bdbd639

Browse files
davidagustinclaude
andcommitted
fix(css): wrap base styles in @layer base for proper cascade
The `* { margin: 0; }` reset was NOT inside any CSS layer, causing it to override Tailwind's layered utilities like `mx-auto`. In CSS Cascade Layers, unlayered styles always beat layered styles, which broke all margin, padding, and other reset-affected utilities. Fixed by wrapping: - Universal reset (*, body) in @layer base - Typography defaults (h1-h6, code, pre) in @layer base - Selection and scrollbar styles in @layer base This allows Tailwind's @layer utilities to properly override base resets. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0c3216d commit bdbd639

File tree

1 file changed

+63
-59
lines changed

1 file changed

+63
-59
lines changed

app/globals.css

Lines changed: 63 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -111,77 +111,81 @@ html.light {
111111

112112
/* Note: Removed @theme inline block to avoid conflicts with Tailwind v4 defaults */
113113

114-
/* Base styles */
115-
* {
116-
margin: 0;
117-
padding: 0;
118-
box-sizing: border-box;
119-
}
114+
/* Base styles - MUST be in @layer base so Tailwind utilities can override them */
115+
@layer base {
116+
* {
117+
margin: 0;
118+
padding: 0;
119+
box-sizing: border-box;
120+
}
120121

121-
body {
122-
background: var(--bg-primary);
123-
color: var(--text-primary);
124-
font-family: var(--font-inter), -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
125-
line-height: 1.6;
126-
-webkit-font-smoothing: antialiased;
127-
-moz-osx-font-smoothing: grayscale;
128-
overflow-x: hidden;
122+
body {
123+
background: var(--bg-primary);
124+
color: var(--text-primary);
125+
font-family: var(--font-inter), -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
126+
line-height: 1.6;
127+
-webkit-font-smoothing: antialiased;
128+
-moz-osx-font-smoothing: grayscale;
129+
overflow-x: hidden;
130+
}
129131
}
130132

131-
/* Typography */
132-
h1,
133-
h2,
134-
h3,
135-
h4,
136-
h5,
137-
h6 {
138-
line-height: 1.2;
139-
font-weight: 700;
140-
letter-spacing: -0.02em;
141-
}
133+
/* Typography and element defaults - in @layer base for proper cascade */
134+
@layer base {
135+
h1,
136+
h2,
137+
h3,
138+
h4,
139+
h5,
140+
h6 {
141+
line-height: 1.2;
142+
font-weight: 700;
143+
letter-spacing: -0.02em;
144+
}
142145

143-
code,
144-
pre {
145-
font-family: var(--font-jetbrains), "Fira Code", "Cascadia Code", monospace;
146-
font-variant-ligatures: common-ligatures;
147-
}
146+
code,
147+
pre {
148+
font-family: var(--font-jetbrains), "Fira Code", "Cascadia Code", monospace;
149+
font-variant-ligatures: common-ligatures;
150+
}
148151

149-
/* Selection */
150-
::selection {
151-
background: rgba(102, 126, 234, 0.3);
152-
color: var(--text-primary);
153-
}
152+
/* Selection */
153+
::selection {
154+
background: rgba(102, 126, 234, 0.3);
155+
color: var(--text-primary);
156+
}
154157

155-
/* Scrollbar - minimal & styled */
156-
::-webkit-scrollbar {
157-
width: 10px;
158-
height: 10px;
159-
}
158+
/* Scrollbar - minimal & styled */
159+
::-webkit-scrollbar {
160+
width: 10px;
161+
height: 10px;
162+
}
160163

161-
::-webkit-scrollbar-track {
162-
background: var(--bg-surface);
163-
}
164+
::-webkit-scrollbar-track {
165+
background: var(--bg-surface);
166+
}
164167

165-
::-webkit-scrollbar-thumb {
166-
background: var(--border-strong);
167-
border-radius: 5px;
168-
}
168+
::-webkit-scrollbar-thumb {
169+
background: var(--border-strong);
170+
border-radius: 5px;
171+
}
169172

170-
::-webkit-scrollbar-thumb:hover {
171-
background: #55556a;
172-
}
173+
::-webkit-scrollbar-thumb:hover {
174+
background: #55556a;
175+
}
173176

174-
/* Light mode scrollbar */
175-
html.light ::-webkit-scrollbar-track {
176-
background: #f4f4f5;
177-
}
177+
/* Light mode scrollbar */
178+
html.light ::-webkit-scrollbar-track {
179+
background: #f4f4f5;
180+
}
178181

179-
html.light ::-webkit-scrollbar-thumb {
180-
background: #d4d4d8;
181-
}
182+
html.light ::-webkit-scrollbar-thumb {
183+
background: #d4d4d8;
184+
}
182185

183-
html.light ::-webkit-scrollbar-thumb:hover {
184-
background: #a1a1aa;
186+
html.light ::-webkit-scrollbar-thumb:hover {
187+
background: #a1a1aa;
188+
}
185189
}
186190

187191
/* Glass morphism utility */

0 commit comments

Comments
 (0)