--- id: wiki-2026-0508-css-architecture-and-styling title: CSS Architecture and Styling category: 10_Wiki/Topics status: verified canonical_id: self aliases: [CSS Patterns, Styling Architecture, CSS Methodologies] duplicate_of: none source_trust_level: A confidence_score: 0.92 verification_status: applied tags: [css, frontend, design-system, web] raw_sources: [] last_reinforced: 2026-05-10 github_commit: pending tech_stack: language: CSS/TS framework: Tailwind v4 / CSS-in-JS / vanilla CSS --- # CSS Architecture and Styling ## 매 한 줄 > **"매 CSS architecture 의 핵심: scope + composition + design tokens + 매 minimize specificity wars"**. 매 2010s OOCSS / BEM / SMACSS, 매 2017 CSS-in-JS, 매 2020 utility-first (Tailwind), 매 2024 native CSS (cascade layers, container queries, `:has()`, nesting, view transitions). 매 2026 현재 Tailwind v4 + CSS Modules + design-token system 의 dominant. ## 매 핵심 ### 매 architecture pillars - **Scoping**: 매 CSS Modules / Shadow DOM / Tailwind atomic / Vue scoped. - **Tokens**: 매 design tokens (`--color-primary`) — 매 single source of truth. - **Cascade layers**: 매 `@layer` — 매 explicit specificity ordering. - **Container queries**: 매 component-level responsive (not viewport). - **Logical properties**: 매 `margin-inline` — 매 i18n RTL/LTR free. ### 매 modern CSS features (2026 baseline) - `@layer reset, base, components, utilities;` - `@container (min-width: 30rem) { ... }` - `:has(> img)` parent selector. - Native nesting `&` (no preprocessor needed). - `view-transition-name: card-hero;` for smooth navigation. - `color-mix(in oklch, var(--brand) 80%, white)`. ### 매 응용 1. Design systems (Radix, shadcn/ui, Material 3). 2. Multi-brand white-label apps (token theming). 3. Email templates (limited subset). 4. Cross-platform (web + React Native via NativeWind). ## 💻 패턴 ### Design tokens with CSS custom properties ```css :root { --color-bg: oklch(98% 0.01 250); --color-fg: oklch(20% 0.03 250); --color-brand: oklch(60% 0.18 260); --space-1: 0.25rem; --space-2: 0.5rem; --radius: 0.5rem; } [data-theme="dark"] { --color-bg: oklch(15% 0.02 250); --color-fg: oklch(95% 0.01 250); } ``` ### Cascade layers (specificity sanity) ```css @layer reset, base, components, utilities; @layer reset { *, *::before, *::after { box-sizing: border-box; margin: 0; } } @layer components { .btn { background: var(--color-brand); color: white; padding: var(--space-2) var(--space-4); border-radius: var(--radius); } } @layer utilities { .mt-4 { margin-top: 1rem; } } ``` ### Container queries ```css .card-grid { container-type: inline-size; } @container (min-width: 30rem) { .card { display: grid; grid-template-columns: 1fr 2fr; } } ``` ### Tailwind v4 (CSS-first config) ```css @import "tailwindcss"; @theme { --color-brand: oklch(60% 0.18 260); --font-display: "Inter Display", sans-serif; --breakpoint-3xl: 120rem; } @utility scrollbar-hidden { scrollbar-width: none; &::-webkit-scrollbar { display: none; } } ``` ### CSS Modules (Vite/Next) ```tsx // Button.module.css .btn { background: var(--color-brand); } .btn:hover { filter: brightness(1.1); } // Button.tsx import s from "./Button.module.css"; export const Button = (p) =>