body.page .middle {
    vertical-align: top;
}

.landing-page-image {
    align-items: flex-start;
    order: 2;
}

.landing-page-content {
    order: 1;
}

header.compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 32px;
    margin-bottom: 0;
    text-align: left;
}

header.compact .title {
    font-size: 28px;
}

header.compact nav {
    margin: 0;
    text-align: right;
}

header.compact nav ul {
    display: flex;
    gap: 0;
    margin: 0;
    padding: 0;
}

header.compact nav li {
    font-size: 18px;
}

a.code-link {
    font-size: 0.85em;
}

/* Publications list */
.pub-list {
    display: flex;
    flex-direction: column;
    gap: 1.1em;
    margin: 0;
    padding: 0;
}

.pub-entry {
    display: flex;
    align-items: flex-start;
    gap: 1em;
}

.pub-venue {
    flex-shrink: 0;
    width: 3em;
    text-align: right;
    font-size: 0.85em;
    color: var(--fg-45);
    padding-top: 0.1em;
}

.pub-body {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.pub-body > div {
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.pub-authors {
    font-size: 0.9em;
    color: rgba(51, 51, 51, 0.7);
}

.pub-meta {
    font-size: 0.9em;
    color: rgba(51, 51, 51, 0.55);
}

.pub-links {
    display: flex;
    gap: 1em;
    margin-top: 0.1em;
    font-size: 0.85em;
}

.pub-badge {
    display: inline-block;
    font-size: 0.75em;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 0.1em;
    color: var(--accent);
    vertical-align: 0.1em;
    white-space: nowrap;
}


.post-title-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1.5em;
}

.post-title-row h1 {
    flex: 1;
    min-width: 0;
    margin: 0;
    text-align: left;
}

.post-title-row time {
    flex-shrink: 0;
    width: auto;
    white-space: nowrap;
    text-align: right;
    margin: 0;
}

@media only screen and (max-width: 600px) {
    header.compact {
        flex-direction: column;
        align-items: center;
        gap: 8px;
        text-align: center;
    }

    header.compact nav {
        text-align: center;
    }

    header.compact nav ul {
        flex-direction: column;
        align-items: center;
        gap: 0.25em;
    }

    /* Nav: stack items vertically, remove bullets */
    nav ul {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.25em;
    }

    nav li {
        font-size: 20px;
    }

    /* Landing page: float image right so text wraps around it */
    .landing-page-wrapper {
        display: block;
    }

    .landing-page-image {
        float: right;
        width: 120px;
        margin: 0 0 0.75em 1em;
        display: block;
    }

    .landing-page-content {
        display: block;
        width: 100%;
    }
}

/* Notes list */
.notes-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 1.5rem;
}

.note-card {
    text-decoration: none !important;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1.1rem;
    padding: 1rem 0;
    border-bottom: 1px solid rgba(51, 51, 51, 0.12);
    color: #333333;
    transition: color 0.15s ease;
}

.notes-grid .note-card:first-child {
    border-top: 1px solid rgba(51, 51, 51, 0.12);
}

.note-card:hover {
    text-decoration: none !important;
}

.note-card:hover .note-card-title {
    color: #D96704;
}

.note-card-image {
    flex-shrink: 0;
    width: 108px;
    height: 108px;
    overflow: hidden;
    border-radius: 2px;
}

.note-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.note-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
}

.note-card-date {
    font-size: 0.85em;
    color: rgba(51, 51, 51, 0.45);
    letter-spacing: 0.05em;
}

.note-card-title {
    font-family: 'Bree Serif', serif;
    font-size: 1.2em;
    font-weight: 700;
    line-height: 1.3;
    color: #333333;
    transition: color 0.15s ease;
}

.note-card-desc {
    font-size: 1em;
    color: rgba(51, 51, 51, 0.6);
    line-height: 1.5;
    margin: 0;
}

/* === Theme tokens === */
:root {
    --bg: #fcfbf9;
    --fg: #333333;
    --accent: #D96704;
    --fg-70: rgba(51, 51, 51, 0.70);
    --fg-60: rgba(51, 51, 51, 0.60);
    --fg-55: rgba(51, 51, 51, 0.55);
    --fg-45: rgba(51, 51, 51, 0.45);
    --fg-35: rgba(51, 51, 51, 0.35);
    --fg-20: rgba(51, 51, 51, 0.20);
    --fg-12: rgba(51, 51, 51, 0.12);
    --code-bg: rgba(3, 4, 6, 0.08);
}

@media (prefers-color-scheme: dark) {
    html:not(.light) {
        --bg: #1c1b1a;
        --fg: #e6e3dc;
        --accent: #f09030;
        --fg-70: rgba(230, 227, 220, 0.70);
        --fg-60: rgba(230, 227, 220, 0.60);
        --fg-55: rgba(230, 227, 220, 0.55);
        --fg-45: rgba(230, 227, 220, 0.45);
        --fg-35: rgba(230, 227, 220, 0.35);
        --fg-20: rgba(230, 227, 220, 0.20);
        --fg-12: rgba(230, 227, 220, 0.12);
        --code-bg: rgba(230, 227, 220, 0.08);
    }
}

html.dark {
    --bg: #1c1b1a;
    --fg: #e6e3dc;
    --accent: #f09030;
    --fg-70: rgba(230, 227, 220, 0.70);
    --fg-60: rgba(230, 227, 220, 0.60);
    --fg-55: rgba(230, 227, 220, 0.55);
    --fg-45: rgba(230, 227, 220, 0.45);
    --fg-35: rgba(230, 227, 220, 0.35);
    --fg-20: rgba(230, 227, 220, 0.20);
    --fg-12: rgba(230, 227, 220, 0.12);
    --code-bg: rgba(230, 227, 220, 0.08);
}

/* Color overrides via tokens (apply in all modes; light tokens match compiled defaults) */
body { background-color: var(--bg); color: var(--fg); }
header .title { color: var(--fg); }
nav { color: var(--fg); }
nav a { color: var(--accent); }
nav a::after { background: var(--accent); }
@media only screen and (max-width: 600px) {
    nav { border-top-color: var(--fg); border-bottom-color: var(--fg); }
}
main { color: var(--fg); }
main a { color: var(--fg); }
main a:hover { text-decoration-color: var(--accent); }
main figcaption { color: var(--fg-70); }
main figcaption a { color: var(--fg-70) !important; }
footer { border-top-color: var(--fg); color: var(--fg); }
footer a { color: var(--fg); }
footer a:hover { text-decoration-color: var(--accent); }
footer .fas:hover, footer .fab:hover, footer .ai:hover { color: var(--accent); }
footer ul li a i { color: var(--fg); }
hr { background: var(--fg); }
kbd { border-color: var(--fg); }
blockquote { border-left-color: var(--accent); }
.footnote-ref, .footnote-backref { color: var(--accent); }
pre, code { background-color: var(--code-bg); }
table > tbody > tr:last-child { border-bottom-color: var(--fg-20); }
th { border-top-color: var(--fg-20); border-bottom-color: var(--fg-20); }
.venue-tag { color: var(--accent); border-color: var(--fg-35); }
.pub-authors { color: var(--fg-70); }
.pub-meta { color: var(--fg-55); }
.note-card { border-bottom-color: var(--fg-12); color: var(--fg); }
.notes-grid .note-card:first-child { border-top-color: var(--fg-12); }
.note-card:hover .note-card-title { color: var(--accent); }
.note-card-date { color: var(--fg-45); }
.note-card-title { color: var(--fg); }
.note-card-desc { color: var(--fg-60); }

/* Theme toggle button */
#theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--fg);
    font-size: 18px;
    padding: 4px 6px;
    opacity: 0.5;
    transition: opacity 0.15s ease, color 0.15s ease;
    line-height: 1;
}
#theme-toggle:hover { opacity: 1; }
