:root {
    --bg: #fafafa;
    --fg: #2e2e2e;
    --heading: #111111;
    --muted: #888888;
    --surface-1: #f0f0f0;
    --surface-2: #ffffff;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #171717;
        --fg: #a1a1a1;
        --heading: #dfdfdf;
        --muted: #888888;
        --surface-1: #1a1a1a;
        --surface-2: #000000;
        --border: rgba(255, 255, 255, 0.1);
        --border-strong: rgba(255, 255, 255, 0.2);
        color-scheme: dark;
    }
}

html {
    scroll-behavior: smooth;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
        sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* --- back link, top of page --- */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: fixed;
    top: 24px;
    left: 24px;
    font-size: 14px;
    color: var(--muted);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface-1);
    border: 0.5px solid var(--border);
    transition:
        color 0.2s ease,
        background 0.2s ease;
}
.back-link:hover {
    color: var(--heading);
}

/* --- post container --- */
.post {
    max-width: 700px;
    margin: 0 auto;
    padding: 96px 24px 120px;
}

.post .date {
    display: block;
    font-size: 15px;
    color: var(--muted);
    margin-bottom: 12px;
    font-family:
        ui-monospace, "SF Mono", "SFMono-Regular", Consolas, "Liberation Mono",
        Menlo, monospace;
}

.post h1 {
    font-size: 40px;
    line-height: 1.15;
    font-weight: 700;
    color: var(--heading);
    margin: 0 0 32px;
}

/* --- long-form content typography --- */
.post-body {
    font-size: 19px;
    line-height: 1.65;
}

.post-body p {
    margin: 0 0 24px;
}
.post-body p:last-child {
    margin-bottom: 0;
}

.post-body h1,
.post-body h2,
.post-body h3 {
    color: var(--heading);
    font-weight: 700;
    margin: 40px 0 16px;
    line-height: 1.3;
}
.post-body h1 {
    font-size: 30px;
}
.post-body h2 {
    font-size: 25px;
}
.post-body h3 {
    font-size: 21px;
}

.post-body a {
    position: relative;
    color: var(--heading);
    text-decoration: none;
    font-weight: 500;
    background-image: linear-gradient(currentColor, currentColor);
    background-size: 0% 1px;
    background-repeat: no-repeat;
    background-position: left bottom;
    transition:
        background-size 0.3s ease,
        color 0.2s ease;
}
.post-body a:hover {
    color: var(--muted);
    background-size: 100% 1px;
}
.post-body sup a,
.post-body sup a:hover {
    background-image: none;
}

.post-body ul,
.post-body ol {
    margin: 0 0 24px;
    padding-left: 24px;
}
.post-body li {
    margin-bottom: 8px;
    line-height: 1.6;
}
.post-body li:last-child {
    margin-bottom: 0;
}

.post-body blockquote {
    margin: 32px 0;
    padding-left: 20px;
    border-left: 2px solid var(--border-strong);
    color: var(--muted);
    font-style: italic;
}

.post-body code {
    font-family:
        ui-monospace, "SF Mono", "SFMono-Regular", Consolas, "Liberation Mono",
        Menlo, monospace;
    font-size: 0.85em;
    background: var(--surface-1);
    border: 0.5px solid var(--border);
    border-radius: 4px;
    padding: 2px 6px;
}

.post-body pre {
    background: var(--surface-1);
    border: 0.5px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    overflow-x: auto;
    margin: 0 0 24px;
}
.post-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 14px;
    line-height: 1.6;
}

.post-body img {
    max-width: 100%;
    height: auto;
    border-radius: 12px;
    margin: 8px 0 24px;
    display: block;
}

.post-body hr {
    border: none;
    border-top: 0.5px solid var(--border);
    margin: 40px 0;
}

.post-body canvas {
    max-width: 100%;
    margin: 8px 0 24px;
}

/* --- responsive --- */
@media screen and (max-width: 720px) {
    .post {
        padding: 80px 20px 80px;
    }
    .post h1 {
        font-size: 30px;
    }
    .post-body {
        font-size: 17px;
    }
    .back-link {
        top: 16px;
        left: 16px;
    }
}

/* --- footnotes --- */
.post-body sup a {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.7em;
    font-weight: 600;
    padding: 0 2px;
}
.post-body sup a:hover {
    color: var(--heading);
}
.post-body ol.footnotes {
    margin-top: 24px;
    padding-top: 8px;
    font-size: 14px;
    color: var(--muted);
}
.post-body ol.footnotes li {
    margin-bottom: 10px;
}
