* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Light mode variables */
:root {
    --bg: #fff;
    --bg-alt: #f9f9f9;
    --text: #222;
    --text-muted: #555;
    --text-faint: #999;
    --border: #eee;
    --nav-bg: #fff;
    --toggle-bg: #ddd;
    --toggle-knob: #fff;
}

/* Dark mode variables */
body.dark {
    --bg: #121212;
    --bg-alt: #1e1e1e;
    --text: #e8e8e8;
    --text-muted: #aaa;
    --text-faint: #666;
    --border: #333;
    --nav-bg: #1a1a1a;
    --toggle-bg: #555;
    --toggle-knob: #fff;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    transition: background 0.3s, color 0.3s;
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 4rem;
    background: var(--nav-bg);
}

nav .nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}

nav .nav-links a {
    text-decoration: none;
    color: var(--text);
    font-size: 0.95rem;
}

nav .nav-links a:hover { 
    color: var(--text-muted); 
}

.hero {
    padding: 8rem 4rem;
    background: var(--bg-alt);
}

.hero h1 {
    font-size: 3.5rem;
    font-weight: 700;
    letter-spacing: -1px;
    margin-bottom: 1rem;
}

.hero p {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 600px;
}

.section {
    padding: 5rem 4rem;
}

.section h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.section p {
    color: var(--text-muted);
    max-width: 700px;
}

footer {
    padding: 2rem 4rem;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 0.85rem;
}

/* Dark mode toggle */
.dark-toggle {
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: 6px;
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: system-ui, sans-serif;
    font-weight: 600;
    transition: background 0.3s, color 0.3s;
    flex-shrink: 0;
}

.dark-toggle:hover {
    opacity: 0.8;
}

/* Blog module */
.blog-post-card { 
    margin-bottom: 2.5rem; 
    padding-bottom: 2.5rem; 
    border-bottom: 
    1px solid var(--border); 
}

.blog-post-card:last-child { 
    border-bottom: none; 
}

.blog-post-image { 
    width: 100%; 
    max-height: 300px; 
    object-fit: cover; 
    border-radius: 8px; 
    margin-bottom: 1rem; 
}

.blog-post-meta { 
    font-size: 0.85rem; 
    color: var(--text-muted); 
    margin-bottom: 0.5rem; 
}

.blog-post-title { 
    font-size: 1.5rem; 
    margin-bottom: 0.5rem; 
}

.blog-post-title a { 
    text-decoration: none; 
    color: var(--text); 
}

.blog-post-title a:hover { 
    text-decoration: underline; 
}

.blog-post-excerpt { 
    color: var(--text-muted); 
    margin-bottom: 0.75rem; 
}

.blog-read-more { 
    font-size: 0.9rem; 
    color: var(--text); 
    font-weight: 600; 
    text-decoration: none; 
}

.blog-read-more:hover { 
    text-decoration: underline; 
}

.blog-tag { 
    display: inline-block; 
    background: var(--bg-alt); 
    border-radius: 20px; 
    padding: 0.1rem 0.5rem; 
    font-size: 0.75rem; 
    margin-left: 0.25rem; 
}

/* Boids simulator */
.boids-section p { margin-bottom: 1.5rem; }
.boids-wrap {
    border-radius: 8px;
    border: 1px solid var(--border);
    overflow: hidden;
    background: #f0f4fa;
    transition: background 0.3s;
}
body.dark .boids-wrap { background: #0a0e1a; }
#boidsCanvas { display: block; width: 100%; cursor: crosshair; }
.boids-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.75rem;
}
.boids-ctrl {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    cursor: default;
}
.boids-ctrl input[type=range] { width: 90px; accent-color: var(--text); }
.boids-ctrl span { font-size: 0.85rem; font-weight: 600; color: var(--text); min-width: 36px; }
.boids-btn {
    font-size: 0.8rem;
    padding: 0.3rem 0.8rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    font-family: system-ui, sans-serif;
    transition: background 0.2s, color 0.2s;
}
.boids-btn:hover { background: var(--bg-alt); }
.boids-btn.active { background: var(--text); color: var(--bg); }
.boids-legend { display: flex; gap: 1.25rem; }
.boids-leg { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-faint); }
.boids-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.boids-dot--boid { background: #185fa5; }
body.dark .boids-dot--boid { background: #4fc3f7; }
.boids-dot--pred { background: #a32d2d; }
body.dark .boids-dot--pred { background: #ef5350; }
.boids-dot--mouse { background: var(--text-faint); }

/* Boids responsive */
@media (max-width: 768px) {
    .boids-wrap canvas {
        min-height: 300px;
    }
    .boids-controls {
        gap: 0.75rem;
    }
    .boids-ctrl input[type=range] {
        width: 70px;
    }
}

@media (max-width: 768px) {
    .section {
        padding: 3rem 1.5rem;
    }
    nav {
        padding: 1rem 1.5rem;
    }
    .hero {
        padding: 4rem 1.5rem;
    }
    .hero h1 {
        font-size: 2.2rem;
    }
}
