:root {
    --text: #1a1a1a;
    --bg: #fafaf7;
    --link: #b5442d;
    --link-visited: #8b5e3c;
    --accent: #888;
    --pop: #b5442d;
    --code-bg: #f0ede6;
    --code-text: #3a3a3a;
    --border: #e0ddd5;
    --font-body: Charter, 'Bitstream Charter', 'Sitka Text', Cambria, serif;
    --font-heading: 'Inter', system-ui, -apple-system, sans-serif;
    --font-code: ui-monospace, 'Cascadia Code', Menlo, Consolas, monospace;
    --measure: 62ch;
    --base: 1.15rem;
    --leading: 1.7;
}

@media (prefers-color-scheme: dark) {
    :root {
        --text: #e0ddd5;
        --bg: #161614;
        --link: #e07a5f;
        --link-visited: #c9a86c;
        --accent: #888;
        --pop: #e07a5f;
        --code-bg: #222220;
        --code-text: #d4d0c8;
        --border: #333;
    }

    img { filter: brightness(.85) contrast(1.1); }
}

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-text-size-adjust: 100%;
    text-rendering: optimizeLegibility;
    hanging-punctuation: first last;
}

body {
    font-family: var(--font-body);
    font-size: var(--base);
    line-height: var(--leading);
    color: var(--text);
    background-color: var(--bg);
    margin: 0;
    padding: 0;
    overflow-y: scroll;
}

/* layout */
nav div, main {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 0 1.5rem;
}

main {
    padding-bottom: 4rem;
}

/* nav */
nav {
    position: sticky;
    top: 0;
    background-color: var(--bg);
    padding: 0.8rem 0;
    z-index: 10;
}

nav div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

nav h1 {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 800;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

nav h1 a, nav h1 a:visited {
    color: var(--text);
    text-decoration: none;
}

nav ul {
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.2rem;
    list-style: none;
}

nav li {
    font-family: var(--font-heading);
    font-size: 0.8rem;
    letter-spacing: 0.02em;
}

nav li a, nav li a:visited, nav a, nav a:visited {
    color: var(--accent);
    text-decoration: none;
    padding: 0.2em 0.45em;
    transition: color 0.15s;
}

nav li a:hover { color: var(--pop); }

nav details > summary {
    list-style: none;
    cursor: pointer;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--accent);
    padding: 0.2em 0.45em;
}

nav details > summary::marker,
nav details > summary::-webkit-details-marker { display: none; }
nav details > summary:hover { color: var(--pop); }

#style-select {
    min-width: 100%;
    cursor: pointer;
    padding: 0.4rem 0;
    position: absolute;
    z-index: 100;
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: 3px;
    margin-top: 0.3em;
    box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

#style-select li {
    display: block;
    padding: 0.35em 1em;
    margin: 0;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    color: var(--text);
}

#style-select li:hover { background-color: var(--code-bg); }

/* headings */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 800;
    line-height: 1.2;
    color: var(--text);
    letter-spacing: -0.02em;
}

article h1, section h1 {
    font-size: 2.6rem;
    text-align: left;
    margin: 2.5rem 0 0.3rem;
}

h2 {
    font-size: 1.5rem;
    margin: 3rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 2px solid var(--pop);
}

article h2 {
    text-align: left;
}

h3 {
    font-size: 1.2rem;
    margin: 2rem 0 0.5rem;
    color: var(--pop);
}

h4, h5, h6 {
    font-size: var(--base);
    margin: 1.5rem 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
}

header h1 a, header h1 a:visited {
    color: var(--text);
    text-decoration: none;
}

/* body */
p {
    font-size: var(--base);
    line-height: var(--leading);
    margin: 0 0 1.3rem;
}

time {
    display: block;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--accent);
    margin-bottom: 2.5rem;
}

/* links */
a {
    color: var(--link);
    text-decoration-line: underline;
    text-decoration-color: var(--pop);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 2px;
    transition: text-decoration-color 0.15s;
}

a:visited { color: var(--link-visited); text-decoration-color: var(--link-visited); }
a:hover { text-decoration-thickness: 2.5px; }

/* lists */
ul, ol {
    padding-left: 1.3em;
    margin: 0 0 1.3rem;
}

li {
    font-size: var(--base);
    line-height: var(--leading);
    margin-bottom: 0.3rem;
}

li > ul, li > ol { margin: 0.3rem 0 0; }

li::marker { color: var(--pop); }

section ul { margin: 0; }
section li, ol li { line-height: var(--leading); list-style-position: outside; }

/* code */
code {
    font-family: var(--font-code);
    font-size: 0.87em;
    color: var(--code-text);
    background-color: var(--code-bg);
    padding: 0.12em 0.35em;
    border-radius: 3px;
}

pre {
    margin: 0 0 1.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

pre code {
    display: block;
    padding: 1.2rem 1.4rem;
    font-size: 0.82rem;
    line-height: 1.6;
    border-radius: 4px;
    border-left: 3px solid var(--pop);
}

/* blockquote */
blockquote {
    border-left: 3px solid var(--pop);
    margin: 2rem 0;
    padding: 0.5rem 0 0.5rem 1.5rem;
    font-style: italic;
}

blockquote p {
    font-size: 1.15em;
    color: var(--accent);
}

/* hr */
hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, var(--pop), transparent);
    margin: 3rem 0;
}

/* images */
img {
    display: block;
    margin: 2rem auto;
    max-width: 100%;
    height: auto;
}

video { max-width: 100%; }

/* tables */
table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.95rem;
}

th, td {
    text-align: left;
    padding: 0.55rem 0.8rem;
    border-bottom: 1px solid var(--border);
}

th {
    font-weight: 700;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
}

/* emphasis */
strong { font-weight: 700; }
i, em { font-style: italic; }

/* archive */
#archive ol { padding: 0; }

#archive ol li {
    list-style: none;
    margin: 1.2rem 0;
    font-size: 1.3rem;
}

/* footer */
footer ul {
    margin: 4rem 0 0;
    padding: 2rem 0 0;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: center;
    gap: 0.8rem;
    list-style: none;
}

footer li { font-size: 0.8rem; }
footer li a { color: var(--accent); }
footer li a:hover { color: var(--pop); }

/* mobile */
@media (max-width: 600px) {
    :root { --base: 1.05rem; }

    nav div { flex-direction: column; gap: 0.4rem; }
    nav h1 { text-align: center; }
    nav ul { justify-content: center; flex-wrap: wrap; }
    #style-select { left: 0; right: 0; }

    article h1, section h1 { font-size: 2rem; }
    h2 { font-size: 1.3rem; }

    img, video { max-width: 100%; }
    code, pre code { white-space: pre-wrap; word-wrap: break-word; }
    pre code { padding: 1rem; font-size: 0.78rem; }
}

/* print */
@media print {
    body { background: white; color: black; font-size: 11pt; }
    nav, footer, #style-select { display: none; }
    a { color: black; }
    pre code { border-left-color: #ccc; font-size: 9pt; }
    h2 { border-bottom-color: #ccc; }
    p { break-inside: avoid; }
}
