:root {
    /* === SPACING SYSTEM === */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 20px;
    --space-2xl: 24px;
    --space-3xl: 32px;
    --space-4xl: 48px;

    /* === LAYOUT === */
    --container-max-width: 1200px;
    --container-padding: var(--space-lg);
    --border-radius-sm: 4px;
    --border-radius-md: 8px;
    --border-radius-lg: 12px;

    /* === TYPOGRAPHY === */
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --line-height-tight: 1.25;
    --line-height-base: 1.6;
    --line-height-loose: 1.8;
    --font-weight-light: 300;
    --font-weight-normal: 400;
    --font-weight-medium: 500;
    --font-weight-semibold: 600;

    /* === COLORS === */
    --text-primary: #000000;
    --text-secondary: #222222;
    --text-muted: #444444;

    /* Primary colors */
    --color-primary-50: #ecfdf5;
    --color-primary-100: #d1fae5;
    --color-primary-200: #a7f3d0;
    --color-primary-300: #6ee7b7;
    --color-primary-400: #34d399;
    --color-primary-500: #10b981;
    --color-primary-600: #059669;
    --color-primary-700: #047857;
    --color-primary-800: #065f46;
    --color-primary-900: #064e3b;

    /* Surface colors */
    --color-surface-50: #ffffff;
    --color-surface-100: #f9fafb;
    --color-surface-200: #f3f4f6;
    --color-surface-300: #e5e7eb;
    --color-surface-400: #d1d5db;
    --color-surface-500: #9ca3af;
    --color-surface-600: #6b7280;
    --color-surface-700: #374151;
    --color-surface-800: #1f2937;
    --color-surface-900: #111827;

    /* === SEMANTIC COLORS === */
    --color-background: var(--color-surface-50);
    --color-surface: var(--color-surface-100);
    --color-border: var(--color-surface-300);
    --color-border-hover: var(--color-surface-400);

    /* === SHADOWS === */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* === TRANSITIONS === */
    --transition-fast: 150ms ease;
    --transition-base: 300ms ease;
    --transition-slow: 600ms ease;
}

html[data-theme="dark"] {
    /* === DARK THEME OVERRIDES === */
    --text-primary: #eeeeee;
    --text-secondary: #cccccc;
    --text-muted: #aaaaaa;

    /* Dark surface colors */
    --color-background: var(--color-surface-900);
    --color-surface: var(--color-surface-800);
    --color-border: var(--color-surface-700);
    --color-border-hover: var(--color-surface-600);

    /* Adjust shadows for dark theme */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
}

/* === RESET & BASE STYLES === */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    min-height: 100vh;
    line-height: var(--line-height-base);
    font-weight: var(--font-weight-light);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--color-background);
    color: var(--text-primary);
    transition: background-color var(--transition-base), color var(--transition-base);
    
    /* Layout */
    display: grid;
    grid-template-rows: auto 1fr auto;
    grid-template-areas: 
        "header"
        "main"
        "footer";
}

/* === TYPOGRAPHY === */
h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-tight);
    font-weight: var(--font-weight-semibold);
    color: var(--text-primary);
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }

p {
    color: var(--text-secondary);
    line-height: var(--line-height-base);
}

a {
    color: var(--color-primary-600);
    text-decoration: none;
    transition: color var(--transition-fast);
    position: relative;
    display: inline-block;
}

a:hover {
    color: var(--color-primary-700);
    text-decoration: none;
}

a:focus {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
    border-radius: var(--border-radius-sm);
}

a::after {
    content: "";
    position: absolute;
    left: 0;
    /* sit just below the text */
    bottom: -2px;
    height: 2px;
    width: 0%;
    background: currentColor;
    transform-origin: left center;
    transition: width var(--transition-slow);
    pointer-events: none;
}

a:hover::after,
a:focus::after {
   width: 100%;
}

@media (prefers-reduced-motion: reduce) {
    a::after {
        transition: none !important;
    }
}

/* === CONTAINER SYSTEM === */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--container-padding);
}

@media (max-width: 768px) {
    .container {
        padding: 0 var(--space-lg);
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-md);
    }
}

/* === LAYOUT COMPONENTS === */
header {
    grid-area: header;
    background-color: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
}

.header-content h1 {
    font-weight: var(--font-weight-medium);
    letter-spacing: -0.025em;
}

main {
    grid-area: main;
    padding: var(--space-4xl) 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

main .container {
    display: flex;
    justify-content: center;
    align-items: center;
}

.main-content {
    width: 100%;
    max-width: 600px;
    text-align: center;
}

article {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-lg);
    padding: var(--space-3xl);
    box-shadow: var(--shadow-md);
    transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

article:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--color-border-hover);
}

article h2 {
    margin-bottom: var(--space-xl);
    color: var(--text-primary);
}

article p {
    font-size: var(--font-size-lg);
    line-height: var(--line-height-loose);
}

footer {
    grid-area: footer;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg) 0;
}

.footer-content p {
    font-size: var(--font-size-sm);
    color: var(--text-muted);
}

/* === THEME SELECTOR === */
.theme-selector {
    display: flex;
    align-items: center;
}

.theme-buttons {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    padding: var(--space-xs);
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    box-shadow: var(--shadow-sm);
}

.theme-btn {
    position: relative;
    width: 40px;
    height: 40px;
    border: 1px solid transparent;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--border-radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.theme-btn:hover {
    background-color: var(--color-surface);
    border-color: var(--color-border);
    color: var(--text-primary);
    transform: scale(1.05);
}

.theme-btn:focus {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

.theme-btn svg {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-base);
}

.theme-btn:hover svg,
.theme-btn:focus svg {
    transform: rotate(180deg);
}

.theme-btn[aria-pressed="true"] {
    background-color: var(--color-primary-50);
    border-color: var(--color-primary-200);
    color: var(--color-primary-700);
    box-shadow: var(--shadow-sm);
}

.theme-btn[aria-pressed="true"] svg {
    transform: rotate(180deg);
}

html[data-theme="dark"] .theme-btn[aria-pressed="true"] {
    background-color: var(--color-primary-900);
    border-color: var(--color-primary-700);
    color: var(--color-primary-300);
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: var(--space-lg);
        padding: var(--space-lg) 0;
    }
    
    .theme-buttons {
        gap: var(--space-xs);
    }
    
    .theme-btn {
        width: 36px;
        height: 36px;
    }
    
    .theme-btn svg {
        width: 18px;
        height: 18px;
    }
    
    main {
        padding: var(--space-2xl) 0;
    }
    
    article {
        padding: var(--space-2xl);
    }
    
    article h2 {
        font-size: var(--font-size-xl);
    }
}

@media (max-width: 480px) {
    .header-content h1 {
        font-size: var(--font-size-2xl);
    }
    
    article {
        padding: var(--space-xl);
    }
    
    article h2 {
        font-size: var(--font-size-lg);
        margin-bottom: var(--space-lg);
    }
    
    article p {
        font-size: var(--font-size-base);
    }
    
    .footer-content {
        flex-direction: column;
        gap: var(--space-md);
        text-align: center;
    }
}

/* === UTILITY CLASSES === */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.focus-visible {
    outline: 2px solid var(--color-primary-500);
    outline-offset: 2px;
}

/* === ANIMATION & TRANSITIONS === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}