:root {
    --bg: #080b12;
    --bg-card: #0c1018;
    --fg: #ccc8bc;
    --accent: #2a8c58;
    --accent-dim: #1d6040;
    --amber: #9a6828;
    --muted: #5a6070;
    --code-bg: #070a10;
    --border: #161c28;
}

/* -- Light mode ------------------------------------------ */

body.light {
    --bg: #f0ede6;
    --bg-card: #e8e4dc;
    --fg: #1a1a18;
    --accent: #1a6840;
    --accent-dim: #145030;
    --amber: #7a5420;
    --muted: #6a6860;
    --code-bg: #e4e0d8;
    --border: #ccc8be;
}
body.light {
    background-color: var(--bg);
    background-image:
        linear-gradient(rgba(20, 80, 50, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(20, 80, 50, 0.04) 1px, transparent 1px);
}
body.light::after {
    opacity: 0.15;
}
body.light::before {
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.02) 3px,
        rgba(0, 0, 0, 0.02) 4px
    );
}
body.light nav {
    background: rgba(240, 237, 230, 0.9);
    border-bottom-color: rgba(204, 200, 190, 0.6);
}
body.light .post-item,
body.light .card {
    background: rgba(232, 228, 220, 0.85);
}
body.light .post-item:hover,
body.light .card:hover {
    background: rgba(232, 228, 220, 0.95);
}
body.light .whisper p { color: #c0bdb5; }
body.light .whisper p.visible { color: var(--muted); }
body.light footer .copy { color: #c0bdb5; }
body.light #field { opacity: 0.35; }

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

body {
    font-family: 'SF Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
    background: var(--bg);
    color: var(--fg);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* -- Blueprint grid -------------------------------------- */
/* Faint drafting grid — like coordinate paper on a CAD terminal */

body {
    background-image:
        linear-gradient(rgba(30, 120, 80, 0.015) 1px, transparent 1px),
        linear-gradient(90deg, rgba(30, 120, 80, 0.015) 1px, transparent 1px);
    background-size: 32px 32px;
    background-position: center center;
}

/* -- CRT texture overlay --------------------------------- */
/* Phosphor dot raster — not film grain, cathode ray tube */

body::after {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9999;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='1' cy='1' r='0.4' fill='%23ffffff' opacity='0.015'/%3E%3Ccircle cx='3' cy='3' r='0.4' fill='%23ffffff' opacity='0.01'/%3E%3C/svg%3E");
    background-size: 4px 4px;
}

/* -- Scanlines (thinner, CRT-accurate) ------------------- */

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 9998;
    pointer-events: none;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0, 0, 0, 0.06) 3px,
        rgba(0, 0, 0, 0.06) 4px
    );
}

a { color: var(--accent); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--fg); }

/* -- Field (full-page code layer) ------------------------ */

#field {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* -- Content layer --------------------------------------- */

#content {
    position: relative;
    z-index: 1;
}

/* -- Nav ------------------------------------------------- */

nav {
    padding: 14px 0;
    position: sticky;
    top: 0;
    background: rgba(8, 11, 18, 0.9);
    backdrop-filter: blur(16px);
    z-index: 100;
    border-bottom: 1px solid rgba(22, 28, 40, 0.6);
}
nav .container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--fg);
    text-decoration: none;
}
.logo span { color: var(--accent); }
.nav-links { display: flex; gap: 24px; align-items: center; }
.nav-links a {
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.5px;
}
.nav-links a:hover, .nav-links a.active { color: var(--accent); }

.nav-toggle { display: none; background: none; border: none; color: var(--accent); font-size: 20px; cursor: pointer; }

.mode-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 2px;
    transition: all 0.2s;
    line-height: 1;
}
.mode-toggle:hover { color: var(--accent); border-color: var(--accent); }

@media (max-width: 640px) {
    .nav-toggle { display: block; }
    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0; right: 0;
        background: rgba(8, 11, 18, 0.96);
        backdrop-filter: blur(16px);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        padding: 16px 24px;
        gap: 16px;
    }
    .nav-links.open { display: flex; }
}

/* -- Containers ------------------------------------------ */

.container { max-width: 960px; margin: 0 auto; padding: 0 24px; }
.container--narrow { max-width: 720px; }

/* -- Hero ------------------------------------------------ */

.hero {
    padding: 140px 0 120px;
    text-align: center;
}
.hero h1 {
    font-size: 48px;
    font-weight: 700;
    letter-spacing: -1.5px;
    line-height: 1.1;
    margin-bottom: 24px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.hero h1 span {
    color: var(--accent);
    text-shadow: 0 0 40px rgba(42, 140, 88, 0.1);
}
.hero .sub {
    font-size: 16px;
    color: var(--muted);
    max-width: 520px;
    margin: 0 auto 40px;
    line-height: 1.7;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

@media (max-width: 640px) {
    .hero { padding: 80px 0 60px; }
    .hero h1 { font-size: 30px; letter-spacing: -0.5px; }
    .hero .sub { font-size: 15px; }
}

/* -- Buttons --------------------------------------------- */

.btn {
    display: inline-block;
    padding: 10px 24px;
    border-radius: 1px;
    font-size: 13px;
    font-weight: 600;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}
.btn-primary {
    background: var(--accent);
    color: var(--bg);
}
.btn-primary:hover { background: var(--fg); color: var(--bg); }
.btn-outline {
    border: 1px solid var(--border);
    color: var(--muted);
    background: transparent;
}
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-group { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* -- Sections -------------------------------------------- */

.page-section { padding: 100px 0; }

.section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--accent);
    margin-bottom: 48px;
}

/* -- Whisper --------------------------------------------- */

.whisper {
    text-align: center;
    padding: 60px 0 80px;
}
.whisper p {
    font-size: 16px;
    color: #1e2430;
    font-weight: 400;
    letter-spacing: 1px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    transition: color 1.5s;
}
.whisper p.visible { color: var(--muted); }

/* -- Writing --------------------------------------------- */

.writing-section { padding: 100px 0; }
.writing-section .section-label { text-align: left; }
.writing-lead {
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.writing-sub {
    font-size: 15px;
    color: var(--muted);
    margin-bottom: 48px;
    max-width: 480px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

.post-list { display: flex; flex-direction: column; gap: 16px; }
.post-item {
    display: block;
    padding: 24px;
    background: rgba(12, 16, 24, 0.82);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 1px;
    transition: all 0.3s;
    text-decoration: none;
}
.post-item:hover {
    border-color: var(--accent-dim);
    background: rgba(12, 16, 24, 0.95);
}
.post-date { font-size: 11px; color: var(--amber); text-transform: uppercase; letter-spacing: 1.5px; }
.post-title { font-size: 18px; font-weight: 700; color: var(--fg); margin: 8px 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.post-excerpt { font-size: 14px; color: var(--muted); line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.post-item .read-more {
    display: inline-block;
    margin-top: 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
}
.post-item:hover .read-more { color: var(--fg); }

/* -- Projects -------------------------------------------- */

.projects-section { padding: 80px 0 120px; }
.projects-section .section-label { text-align: left; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}
.card {
    background: rgba(12, 16, 24, 0.82);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border);
    border-radius: 1px;
    padding: 24px;
    transition: all 0.3s;
}
.card:hover {
    border-color: var(--accent-dim);
    background: rgba(12, 16, 24, 0.95);
}
.card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; color: var(--fg); }
.card p { font-size: 13px; color: var(--muted); line-height: 1.6; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.card .tag {
    display: inline-block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--amber);
    margin-bottom: 12px;
}
.card .card-link {
    display: inline-block;
    margin-top: 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.5px;
}
.card .card-link:hover { color: var(--fg); }

/* -- Footer ---------------------------------------------- */

footer {
    padding: 40px 0;
    border-top: 1px solid rgba(22, 28, 40, 0.4);
}
footer .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}
footer .copy { font-size: 12px; color: #1e2430; }
footer .footer-links { display: flex; gap: 20px; }
footer .footer-links a { font-size: 12px; color: var(--muted); }
footer .footer-links a:hover { color: var(--accent); }

@media (max-width: 640px) {
    footer .container { flex-direction: column; text-align: center; }
}

/* -- Article --------------------------------------------- */

.article-header {
    padding: 80px 0 40px;
    text-align: center;
}
.article-header h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.15;
    margin-bottom: 12px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
.article-meta { font-size: 12px; color: var(--muted); letter-spacing: 0.5px; }
.article-body { padding: 0 0 80px; }
.article-body h2 { font-size: 22px; font-weight: 700; margin: 40px 0 16px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.article-body h3 { font-size: 17px; font-weight: 700; margin: 32px 0 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.article-body p { font-size: 15px; color: var(--muted); line-height: 1.7; margin-bottom: 16px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.article-body p strong { color: var(--fg); }
.article-body ul, .article-body ol { margin: 0 0 16px 24px; color: var(--muted); font-size: 15px; line-height: 1.7; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
.article-body code {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 1px;
    padding: 2px 6px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 13px;
    color: var(--accent);
}
.article-body pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 1px;
    padding: 20px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.7;
    overflow-x: auto;
    margin-bottom: 16px;
}
.article-body pre code { background: none; border: none; padding: 0; color: var(--fg); }
.article-body blockquote {
    border-left: 2px solid var(--accent);
    padding-left: 20px;
    margin: 24px 0;
    font-style: italic;
    color: var(--muted);
}

/* -- Form ------------------------------------------------ */

.form-group { margin-bottom: 20px; }
.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--amber);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 2px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 1px;
    color: var(--fg);
    font-size: 14px;
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(42, 140, 88, 0.08);
}
.form-group textarea { resize: vertical; min-height: 120px; }
