:root {
    --bg: #fdfdfb;
    --text: #222;
    --muted: #666;
    --link: #1a5fb4;
    --line: #ddd;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #181818;
        --text: #e6e6e6;
        --muted: #999;
        --link: #78aeed;
        --line: #333;
    }
}

* {
    box-sizing: border-box;
}

html {
    --scale: 2;
    --tile: calc(8px * var(--scale));
    --frame: calc(64px * var(--scale));
    --top-gap: calc(
        192px * var(--scale)
    ); /* transparent space above the frame */
    --min-w: calc(
        2 * var(--frame) + 20rem
    ); /* borders + minimum content width */
    --w: max(100%, var(--min-w));
    background-color: var(--bg);
    overflow-x: hidden; /* keeps body's overflow from moving to the viewport */
}

body {
    position: relative;
    isolation: isolate;
    overflow-x: clip;
    margin: 0;
    min-height: 100vh;
    padding-block: calc(var(--frame) + var(--top-gap)) var(--frame);
    padding-inline: max(0px, calc(var(--frame) + (100% - var(--w)) / 2));
    image-rendering: pixelated;
    color: var(--text);
    /* keep the existing font rules below */
}

body::before {
    content: "";
    position: absolute;
    z-index: -1;
    top: var(--top-gap);
    bottom: 0;
    left: calc((100% - var(--w)) / 2);
    width: var(--w);
    box-sizing: border-box;
    border: var(--frame) solid transparent;
    border-image: url("frame.png") 64 round;
    background: url("center.png") 0 0 / var(--tile) var(--tile) repeat;
    background-clip: padding-box;
    pointer-events: none;
}

body::after {
    content: "";
    position: fixed;
    z-index: -2; /* still below the frame (-1) */
    inset: 0;
    background: url("earthlike.png") top / auto calc(192px * var(--scale))
        no-repeat;
    image-rendering: pixelated;
    pointer-events: none;
}

a {
    color: var(--link);
}

.wrap {
    max-width: 40rem;
    margin: 0 auto;
    padding: 1.25rem 1.25rem;
}

header {
    border-bottom: 1px solid var(--line);
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

header h1 {
    margin: 0;
    font-size: 1.6rem;
}

header h1 a {
    color: inherit;
    text-decoration: none;
}

nav {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

article {
    margin-bottom: 2.5rem;
}

article h2 {
    margin: 0 0 0.25rem;
    font-size: 1.35rem;
}

.date {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 0 0 0.75rem;
}

footer {
    border-top: 1px solid var(--line);
    padding-top: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.stars {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: -3; /* below body::after (-2) and body::before (-1) */
    image-rendering: pixelated;
    pointer-events: none;
}
