:root {
    --bg: #f9fdf9;
    --bg-alt: #f0f6f0;
    --bg-topbar: #e8f0e8;
    --text: #111;
    --text-muted: #555;
    --accent: #2d5a2d;
    --link: #1a6a1a;
    --link-hover: #0d4a0d;
    --border: #c8d8c8;
    --border-light: #dce8dc;
}

[data-theme="dark"] {
    --bg: #050a05;
    --bg-alt: #0a120a;
    --bg-topbar: #0c180c;
    --text: #f0f0f0;
    --text-muted: #aaa;
    --accent: #6cb86c;
    --link: #7dce7d;
    --link-hover: #9de09d;
    --border: #1a2a1a;
    --border-light: #152015;
}

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

html {
    font-size: 19px;
}

body {
    font-family: 'Crimson Pro', Georgia, serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--link);
    text-decoration: none;
}

a:hover {
    color: var(--link-hover);
    text-decoration: underline;
}

/* Top Bar */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-name {
    font-family: 'Crimson Pro', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
}

.site-name:hover {
    text-decoration: none;
}

.topbar-nav a {
    color: var(--text-muted);
    margin-right: 1.5rem;
}

.topbar-nav a:hover,
.topbar-nav a.active {
    color: var(--text);
    text-decoration: none;
}

.topbar-right {
    display: flex;
    gap: 1rem;
    align-items: center;
    color: var(--text-muted);
}

.theme-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    color: var(--text-muted);
    border-radius: 3px;
    transition: all 0.15s;
}

.theme-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

/* Main Container */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 5rem 2rem 3rem;
}

.container--narrow {
    max-width: 750px;
}

.container--cv {
    max-width: 800px;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 3rem;
}

.hero h1 {
    font-size: 2.8rem;
    font-weight: 500;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.hero-bio {
    font-size: 1.15rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 1.5rem;
}

.hero-links {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
}

.hero-links a {
    color: var(--text-muted);
    padding: 0.4rem 0;
    border-bottom: 1px solid transparent;
    transition: all 0.15s;
}

.hero-links a:hover {
    color: var(--link);
    border-bottom-color: var(--link);
    text-decoration: none;
}

/* Articles Grid */
.articles-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

.articles-column h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent);
    margin-bottom: 1rem;
    text-transform: lowercase;
    font-variant: small-caps;
    letter-spacing: 0.08em;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

.article-list {
    list-style: none;
}

.article-entry {
    padding: 0.7rem 0;
    border-bottom: 1px dotted var(--border);
}

.article-entry:last-child {
    border-bottom: none;
}

.article-title {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    line-height: 1.4;
}

.article-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
}

.article-meta .created::before {
    content: 'created ';
    opacity: 0.7;
}

.article-meta .updated::before {
    content: 'updated ';
    opacity: 0.7;
}

.article-meta .updated {
    color: var(--accent);
}

.substack-badge {
    display: inline-block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.55rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 0.1rem 0.4rem;
    margin-left: 0.5rem;
    border-radius: 2px;
    color: var(--text-muted);
    vertical-align: middle;
}

.show-more {
    display: block;
    text-align: center;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 1rem;
    margin-top: 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 4px;
    transition: all 0.15s;
}

.show-more:hover {
    background: var(--bg-alt);
    color: var(--link);
    text-decoration: none;
}

/* About Page */
.about-header {
    display: flex;
    gap: 2.5rem;
    align-items: flex-start;
    margin-bottom: 2.5rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-light);
}

.about-photo {
    width: 200px;
    height: 200px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    border: 3px solid var(--border-light);
}

.about-header-text h1 {
    font-size: 2.2rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.about-header-text .role {
    font-size: 1.1rem;
    color: var(--text-muted);
    font-style: italic;
    margin-bottom: 1rem;
}

.about-header-text .contact-links {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
}

.about-content h2 {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--accent);
    margin: 2rem 0 1rem;
    text-transform: lowercase;
    font-variant: small-caps;
    letter-spacing: 0.08em;
}

.about-content p {
    margin-bottom: 1rem;
    text-align: justify;
    hyphens: auto;
}

.about-content ul {
    margin: 1rem 0 1rem 1.5rem;
}

.about-content li {
    margin-bottom: 0.5rem;
}

/* CV Page */
.cv-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.cv-header h1 {
    font-size: 2rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.cv-header .subtitle {
    color: var(--text-muted);
    font-style: italic;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 0.5rem 1rem;
    border-radius: 4px;
    color: var(--text);
    transition: all 0.15s;
}

.download-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    text-decoration: none;
}

.cv-section {
    margin-bottom: 2rem;
}

.cv-section h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent);
    text-transform: lowercase;
    font-variant: small-caps;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-light);
}

.cv-entry {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dotted var(--border);
}

.cv-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.cv-date {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    padding-top: 0.2rem;
}

.cv-content .title {
    font-weight: 500;
    margin-bottom: 0.1rem;
}

.cv-content .org {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.cv-content .details {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.pub-entry {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dotted var(--border);
}

.pub-entry:last-child {
    border-bottom: none;
}

.pub-title {
    font-weight: 500;
}

.pub-authors {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.pub-venue {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--accent);
}

.inline-list {
    font-size: 0.95rem;
}

.inline-list strong {
    color: var(--text);
}

/* Post Page */
.post-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-light);
}

.post-header h1 {
    font-size: 2.2rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 0.5rem;
}

.post-meta {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.post-meta .updated {
    color: var(--accent);
}

.post-tags {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.post-tags a {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    background: var(--bg-alt);
    border: 1px solid var(--border);
    padding: 0.15rem 0.5rem;
    border-radius: 3px;
    color: var(--text-muted);
}

.post-tags a:hover {
    border-color: var(--accent);
    color: var(--text);
    text-decoration: none;
}

.post-content {
    line-height: 1.7;
}

.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4 {
    font-weight: 500;
    margin: 2rem 0 1rem;
    color: var(--accent);
}

.post-content h1 { font-size: 1.6rem; }
.post-content h2 { font-size: 1.35rem; }
.post-content h3 { font-size: 1.15rem; }

.post-content p {
    margin-bottom: 1rem;
}

.post-content ul,
.post-content ol {
    margin: 1rem 0 1rem 1.5rem;
}

.post-content li {
    margin-bottom: 0.4rem;
}

.post-content blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1rem;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-style: italic;
}

.post-content pre {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1rem;
    overflow-x: auto;
    margin: 1.5rem 0;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.5;
}

.post-content code {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85em;
    background: var(--bg-alt);
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
}

.post-content pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1rem 0;
}

.post-content figure {
    margin: 1.5rem 0;
    text-align: center;
}

.post-content figcaption {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.5rem;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}

.post-content th,
.post-content td {
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    text-align: left;
}

.post-content th {
    background: var(--bg-alt);
    font-weight: 500;
}

.post-content audio {
    display: block;
    margin: 0.5rem 0 1rem;
    width: 100%;
    max-width: 400px;
}

.post-content .footnotes {
    margin-top: 3rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-light);
    font-size: 0.85rem;
}

.post-content .footnotes hr {
    display: none;
}

/* Archive Page */
.archive-header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-light);
}

.archive-header h1 {
    font-size: 2rem;
    font-weight: 500;
}

.archive-section h2 {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--accent);
    margin: 2rem 0 1rem;
    text-transform: lowercase;
    font-variant: small-caps;
    letter-spacing: 0.08em;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-light);
}

/* Footer */
footer {
    margin-top: 4rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-light);
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.footer-links a {
    color: var(--text-muted);
    margin-left: 1.5rem;
}

.footer-links a:hover {
    color: var(--link);
}

/* Print styles */
@media print {
    .topbar, .theme-btn, footer, .download-btn {
        display: none;
    }
    .container {
        padding-top: 0;
        max-width: 100%;
    }
    body {
        font-size: 11pt;
    }
}

/* Responsive */
@media (max-width: 900px) {
    .articles-grid {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

@media (max-width: 700px) {
    .about-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .about-photo {
        width: 180px;
        height: 180px;
    }

    .about-header-text .contact-links {
        justify-content: center;
    }

    .cv-entry {
        grid-template-columns: 1fr;
        gap: 0.25rem;
    }

    .cv-header {
        flex-direction: column;
        gap: 1rem;
    }
}

@media (max-width: 600px) {
    html {
        font-size: 17px;
    }

    .topbar {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }

    .topbar-left {
        flex-direction: column;
        gap: 0.5rem;
    }

    .hero h1 {
        font-size: 2rem;
    }

    .hero-links {
        flex-wrap: wrap;
        gap: 1rem;
    }

    .container {
        padding: 6rem 1rem 2rem;
    }

    footer {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    .footer-links a {
        margin: 0 0.75rem;
    }
}
