:root {
    --bg: #fdfbf7;
    --text: #2d2d2d;
    --heading-1: #c47545;
    --heading-2: #d97745;
    --heading-3: #b86535;
    --heading-4: #b86535;
    --strong: #b86535;
    --em: #7a5530;
    --small: #666;
    --muted-warm: #8b6540;
    --link: #d97745;
    --link-accent: #d97745;
    --hr: #e8d5c8;
    --border-soft: #f4e5dc;
    --code-bg: #f4e5dc;
    --code-text: #7a3f1a;
    --pre-bg: #faf0e6;
    --pre-border: #f0dccb;
    --pre-accent: #d97745;
    --pre-text: #3a2a1a;
    --blockquote-bg: #faf6f2;
    --blockquote-text: #5a4a3a;
    --blockquote-border: #f4e5dc;
    --table-border: #e8d5c8;
    --table-header-bg: #faf0e6;
    --table-header-text: #b86535;
    --topic-label: #b86535;
    --statement-italic: #3a2a1a;
    --statement-block-bg: #faf6f2;
    --statement-block-accent: #d97745;
    --statement-block-strong: #2d2d2d;
    --proof-opener: #5a4a3a;
    --qed: #b86535;
    --reference: #a08260;
    --tags-sep: #c0a890;
    --footer-text: #666;
    --footer-border: #e8d5c8;
    --select-bg: rgba(217, 119, 69, 0.16);
    --hover-tint: #f7efe7;
    --font-serif: Charter, "Bitstream Charter", "Sitka Text", Cambria, Georgia, "Times New Roman", serif;
    --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

[data-theme="dark"] {
    --bg: #16110e;
    --text: #e6dbc6;
    --heading-1: #ee9560;
    --heading-2: #f5a070;
    --heading-3: #e08a55;
    --heading-4: #e08a55;
    --strong: #f5a070;
    --em: #c4a380;
    --small: #9a8970;
    --muted-warm: #b89770;
    --link: #f5a070;
    --link-accent: #f5a070;
    --hr: #3a2e25;
    --border-soft: #2d241c;
    --code-bg: #2a1f17;
    --code-text: #f0b385;
    --pre-bg: #221a14;
    --pre-border: #3a2e25;
    --pre-accent: #e08a55;
    --pre-text: #e6dbc6;
    --blockquote-bg: #221a14;
    --blockquote-text: #c4a380;
    --blockquote-border: #3a2e25;
    --table-border: #3a2e25;
    --table-header-bg: #2a1f17;
    --table-header-text: #f5a070;
    --topic-label: #ee9560;
    --statement-italic: #e6dbc6;
    --statement-block-bg: #221a14;
    --statement-block-accent: #e08a55;
    --statement-block-strong: #f5a070;
    --proof-opener: #c4a380;
    --qed: #f5a070;
    --reference: #a89070;
    --tags-sep: #5d4a35;
    --footer-text: #9a8970;
    --footer-border: #3a2e25;
    --select-bg: rgba(245, 160, 112, 0.20);
    --hover-tint: #20180f;
}

html {
    scroll-behavior: smooth;
}

::selection {
    background: var(--select-bg);
}

body {
    max-width: 760px;
    margin: 20px auto;
    padding: 0 22px;
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.7;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    font-variant-numeric: oldstyle-nums proportional-nums;
    hanging-punctuation: first last;
    transition: background-color 0.2s ease, color 0.2s ease;
}

p {
    text-wrap: pretty;
}

/* Keep monospaced contexts on plain lining figures. */
code, pre, .theorem-statement, mjx-container {
    font-variant-numeric: normal;
}

h1 {
    color: var(--heading-1);
    font-size: 2.5em;
    margin-bottom: 0.3em;
    letter-spacing: -0.015em;
    line-height: 1.15;
}

h1, h2, h3, h4 {
    text-wrap: balance;
}

h2 {
    color: var(--heading-2);
    font-size: 1.8em;
    margin-top: 1.5em;
    margin-bottom: 0.8em;
    border-bottom: 2px solid var(--border-soft);
    padding-bottom: 0.3em;
}

h3 {
    color: var(--heading-3);
    font-size: 1.3em;
    margin-top: 1.5em;
    margin-bottom: 0.5em;
}

h4 {
    color: var(--heading-4);
    font-size: 1.15em;
    margin-top: 1.3em;
    margin-bottom: 0.4em;
}

a {
    color: var(--link);
    text-decoration: none;
    border-bottom: 1px solid var(--border-soft);
    transition: border-color 0.2s;
}

a:hover {
    border-bottom-color: var(--link-accent);
}

/* Dividers set as a centered fleuron rather than a rule. */
hr {
    border: none;
    height: auto;
    margin: 2.4em 0;
    text-align: center;
    overflow: visible;
}

hr::after {
    content: "\2767";
    display: inline-block;
    color: var(--reference);
    font-size: 1.15em;
    letter-spacing: 0.4em;
    text-indent: 0.4em;
}

strong {
    color: var(--strong);
}

em {
    color: var(--em);
}

small {
    color: var(--small);
}

ul, ol {
    line-height: 1.8;
}

li {
    margin-bottom: 0.3em;
}

/* Navigation */
nav.topnav {
    margin: 0.5em 0 1em 0;
    font-family: var(--font-sans);
    font-size: 0.82em;
    letter-spacing: 0.01em;
    color: var(--tags-sep);
    line-height: 2;
}

nav.topnav a {
    margin-right: 0.5em;
    color: var(--muted-warm);
    border-bottom: none;
}

nav.topnav a:hover {
    color: var(--link-accent);
    border-bottom: none;
}

.theme-toggle {
    font-style: italic;
}

/* Post listing on index */
.post-list {
    list-style: none;
    padding: 0;
}

.post-list li {
    margin-bottom: 1.4em;
}

.post-list .post-title {
    font-size: 1.25em;
    color: var(--heading-3);
    display: block;
    border-bottom: none;
}

.post-list .post-title:hover {
    border-bottom: 1px solid var(--link-accent);
}

.post-list .post-meta {
    color: var(--muted-warm);
    font-size: 0.9em;
    font-style: italic;
}

.post-list .post-tags {
    font-size: 0.85em;
    color: var(--muted-warm);
}

.post-list .post-tags span {
    margin-right: 0.4em;
}

/* Month grouping on listing pages: a quiet time divider above each group. */
.month-group {
    margin: 0 0 1.6em;
}

.month-heading {
    font-variant: small-caps;
    letter-spacing: 0.06em;
    font-weight: normal;
    color: var(--muted-warm);
    font-size: 0.95em;
    margin: 1.8em 0 0.9em;
    padding-bottom: 0.2em;
    border-bottom: 1px solid var(--border-soft);
}

/* Inside a language section the month is a sub-divider, quieter and rule-less. */
.language-group .month-heading {
    border-bottom: none;
    font-size: 0.85em;
    margin: 1.1em 0 0.5em;
}

/* Home section directory: a quiet two-column index. */
.section-list {
    list-style: none;
    padding: 0;
    margin-top: 1.8em;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    column-gap: 2.5em;
    row-gap: 1.8em;
}

.section-list li {
    padding-top: 0.9em;
    border-top: 1px solid var(--border-soft);
}

.section-list .section-title {
    font-size: 1.3em;
    color: var(--heading-2);
    display: inline-block;
    border-bottom: none;
}

.section-list .section-title:hover {
    border-bottom: 1px solid var(--link-accent);
}

.section-list .section-desc {
    color: var(--text);
    font-size: 0.95em;
    margin: 0.25em 0 0.4em;
}

.section-list .section-latest {
    font-family: var(--font-sans);
    font-size: 0.84em;
    color: var(--muted-warm);
}

.section-list .section-latest-date {
    font-style: italic;
    font-size: 0.92em;
    color: var(--muted-warm);
}

/* Individual post */
.post-header {
    margin-bottom: 2em;
}

.post-header h1 {
    margin-bottom: 0.1em;
}

.post-meta-line {
    color: var(--muted-warm);
    font-size: 0.95em;
    font-style: italic;
    margin-top: 0;
}

.post-tags-line {
    color: var(--muted-warm);
    font-size: 0.9em;
}

.post-tags-line span {
    margin-right: 0.4em;
}

.post-content img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1em auto;
}

.post-content p {
    margin: 1em 0;
}

/* Drop cap on the opening line of a long-form essay. */
.kind-blog .post-content > p:first-of-type::first-letter {
    float: left;
    font-size: 3.2em;
    line-height: 0.78;
    margin: 0.02em 0.09em 0 0;
    color: var(--heading-2);
}

/* Printer's end-mark closing essays and writeups. */
.endmark {
    text-align: center;
    color: var(--reference);
    font-size: 1.25em;
    letter-spacing: 0.1em;
    margin: 2.2em 0 0 !important;
    line-height: 1;
}

/* Code */
code {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.1em 0.35em;
    border-radius: 3px;
    font-size: 0.92em;
}

pre {
    background: var(--pre-bg);
    border: 1px solid var(--pre-border);
    border-left: 3px solid var(--pre-accent);
    padding: 0.9em 1em;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.45;
    border-radius: 2px;
}

pre code {
    background: transparent;
    color: var(--pre-text);
    padding: 0;
    font-size: inherit;
}

/* Blockquotes, set like an epigraph rather than a callout */
blockquote {
    border-left: 2px solid var(--blockquote-border);
    padding: 0.1em 0 0.1em 1.3em;
    margin: 1.4em 0;
    color: var(--blockquote-text);
    font-style: italic;
}

blockquote p {
    margin: 0.4em 0;
}

/* Tables */
table {
    border-collapse: collapse;
    margin: 1em 0;
    width: 100%;
}

table th, table td {
    border: 1px solid var(--table-border);
    padding: 0.5em 0.8em;
    text-align: left;
}

table th {
    background: var(--table-header-bg);
    color: var(--table-header-text);
}

/* MathJax display */
mjx-container[display="true"] {
    margin: 1em 0 !important;
    overflow-x: auto;
    overflow-y: hidden;
}

/* Loading state */
#post-content.loading {
    color: var(--muted-warm);
    font-style: italic;
}

footer {
    margin-top: 3em;
    padding-top: 1em;
    border-top: 1px solid var(--footer-border);
    color: var(--footer-text);
    font-size: 0.9em;
}

/* Tags page */
.tag-group h3 {
    margin-top: 1.2em;
}

/* Theorems index */
.theorem-topic {
    margin: 2em 0;
}

/* Languages index */
.language-group {
    margin: 2em 0;
}

.topic-label {
    font-variant: small-caps;
    letter-spacing: 0.08em;
    color: var(--topic-label);
    border-bottom: 1px solid var(--border-soft);
    padding-bottom: 0.25em;
    margin-top: 1.5em;
    margin-bottom: 1em;
    font-size: 1.05em;
}

.theorem {
    margin: 1.4em 0 1.8em;
    padding-left: 0.2em;
}

.theorem-header {
    margin: 0 0 0.4em 0;
    line-height: 1.55;
}

.theorem-header strong {
    color: var(--statement-block-strong);
    font-weight: 600;
}

.theorem-statement {
    font-style: italic;
    color: var(--statement-italic);
}

.theorem-meta {
    margin: 0.3em 0 0 0;
    padding-left: 1.4em;
    font-size: 0.85em;
    color: var(--muted-warm);
}

.theorem-meta .theorem-tags span {
    margin-right: 0.35em;
}

.theorem-meta .theorem-sep {
    margin: 0 0.4em;
    color: var(--tags-sep);
}

.theorem-meta a {
    font-style: italic;
}

.theorem-reference {
    margin: 0.2em 0 0 1.4em !important;
    font-size: 0.82em;
    font-style: italic;
    color: var(--reference);
}

.theorem-statement-block .theorem-reference {
    margin: 0.4em 0 0 0 !important;
}

/* Source / attribution note at the foot of a blog post. */
.post-ref {
    margin-top: 1.6em;
    font-family: var(--font-sans);
    font-size: 0.8em;
    line-height: 1.6;
    color: var(--muted-warm);
}

.post-ref a {
    color: inherit;
}

/* Theorem reader (full page) */
.theorem-statement-block {
    background: var(--statement-block-bg);
    border-left: 3px solid var(--statement-block-accent);
    padding: 0.8em 1.1em;
    margin: 1.5em 0 2em;
    border-radius: 2px;
}

.theorem-statement-block p {
    margin: 0;
    line-height: 1.6;
}

.theorem-statement-block strong {
    color: var(--statement-block-strong);
    font-weight: 600;
}

.proof-opener {
    margin: 1.2em 0 0.8em 0 !important;
    color: var(--proof-opener);
}

.proof-opener em {
    color: var(--proof-opener);
}

.qed {
    text-align: right;
    color: var(--qed);
    font-size: 1.3em;
    margin: 1.5em 0 0 0 !important;
    line-height: 1;
}

/* --- type & interaction polish --- */
.post-list .post-meta,
.post-list .post-tags,
.post-meta-line,
.post-tags-line,
.theorem-meta,
footer {
    font-family: var(--font-sans);
}

/* Quieter, book-style list markers in prose. */
.post-content ul li::marker,
.booklist li::marker {
    content: "\2013\00a0";
    color: var(--reference);
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* Responsive tweaks */
@media (max-width: 600px) {
    body {
        font-size: 16px;
    }
    h1 {
        font-size: 2em;
    }
    h2 {
        font-size: 1.5em;
    }
    .theorem-meta {
        padding-left: 0;
    }
    .section-list {
        grid-template-columns: 1fr;
        row-gap: 1.4em;
    }
}
