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

html {
    font-size: 18px;
}

body {
    font-family: Palatino Linotype, Book Antiqua, Palatino, Georgia, serif;
    font-size: 1rem;
    line-height: 1.8;
    color: #4c4c4c;
    background: #fffffc;
    margin: 0;
    padding: 0;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.container {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ── Nav ─────────────────────────────────────────────────────────────────── */

nav {
    border-bottom: 1px solid #ddd;
    padding: 1.2rem 0;
    margin-bottom: 3rem;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

nav a {
    color: #4c4c4c;
    text-decoration: none;
    margin-right: 1.5rem;
}

nav a:hover {
    text-decoration: underline;
}

/* ── Headings ────────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
    font-family: Palatino Linotype, Book Antiqua, Palatino, Georgia, serif;
    font-weight: bold;
    line-height: 1.25;
    margin: 2rem 0 0.6rem;
    color: #111;
}

h1 {
    font-size: 2.2rem;
    margin-top: 0;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
}

h3 {
    font-size: 1.15rem;
}

h4 {
    font-size: 1rem;
    font-style: italic;
    font-weight: normal;
}

/* ── Anchor links ────────────────────────────────────────────────────────── */

h2, h3, h4 {
    position: relative;
    padding-left: 1.5rem;
    margin-left: -1.5rem;
    border-radius: 3px;
    transition: background 0.15s;
}

h2:hover, h3:hover, h4:hover,
h2.anchor-copied, h3.anchor-copied, h4.anchor-copied {
    background: rgba(0, 0, 0, 0.025);
}

.anchor-icon {
    position: absolute;
    left: 0.15rem;
    top: 50%;
    transform: translateY(-50%);
    width: 1.2rem;
    text-align: center;
    font-size: 0.75em;
    font-weight: normal;
    font-style: normal;
    color: #bbb;
    opacity: 0;
    user-select: none;
    cursor: pointer;
    transition: opacity 0.15s, color 0.15s;
}

h2:hover .anchor-icon,
h3:hover .anchor-icon,
h4:hover .anchor-icon,
h2.anchor-copied .anchor-icon,
h3.anchor-copied .anchor-icon,
h4.anchor-copied .anchor-icon {
    opacity: 1;
}

h2.anchor-copied .anchor-icon,
h3.anchor-copied .anchor-icon,
h4.anchor-copied .anchor-icon {
    color: #5a8a5a;
}

h2.anchor-fading .anchor-icon,
h3.anchor-fading .anchor-icon,
h4.anchor-fading .anchor-icon {
    opacity: 0;
    transition: opacity 0.3s;
}

h2.anchor-fading,
h3.anchor-fading,
h4.anchor-fading {
    background: transparent;
    transition: background 0.3s;
}

/* ── Body text ───────────────────────────────────────────────────────────── */

p {
    margin: 0 0 0.5em;
    hyphens: auto;
}

/* First paragraph after a heading needs no top gap */
h1 + p, h2 + p, h3 + p {
    margin-top: 0;
}

a {
    color: #1a1a1a;
    text-decoration: underline;
    text-decoration-color: #aaa;
    text-underline-offset: 3px;
}

a:hover {
    text-decoration-color: #1a1a1a;
}

strong {
    font-weight: bold;
}

em {
    font-style: italic;
}

/* ── Blockquote ──────────────────────────────────────────────────────────── */

blockquote {
    margin: 2rem 0;
    padding: 0 0 0 1.5rem;
    border-left: 3px solid #ccc;
    color: #444;
    font-style: italic;
}

blockquote p:last-child {
    margin-bottom: 0;
}

blockquote cite {
    display: block;
    margin-top: 0.6rem;
    font-size: 0.85rem;
    font-style: normal;
    color: #777;
    letter-spacing: 0.03em;
}

/* ── Lists ───────────────────────────────────────────────────────────────── */

ul, ol {
    padding-left: 1.5rem;
    margin: 0 0 1.3em;
}

li {
    margin-bottom: 0.3em;
}

/* ── Rule ────────────────────────────────────────────────────────────────── */

hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 2.5rem 0;
}

/* ── Figure & caption ────────────────────────────────────────────────────── */

figure {
    margin: 2rem 0;
}

figcaption {
    font-size: 0.82rem;
    color: #777;
    margin-top: 0.5rem;
    font-style: italic;
    text-align: center;
}

/* ── Code ────────────────────────────────────────────────────────────────── */

code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85em;
    background: #f0ede6;
    padding: 0.1em 0.35em;
    border-radius: 3px;
}

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

pre code {
    background: none;
    padding: 0;
    font-size: 0.88rem;
}

/* Shiki output */
.shiki {
    padding: 1.2rem 1.4rem;
    border-radius: 4px;
    border: 1px solid #e5e0d8;
}

/* ── Metadata / byline ───────────────────────────────────────────────────── */

.byline {
    font-size: 0.82rem;
    color: #777;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 2rem;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 1rem;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    bottom: 1.8rem;
    left: 50%;
    transform: translateX(-50%) translateY(0.4rem);
    background: #1a1a1a;
    color: #f5f5f0;
    font-family: system-ui, -apple-system, sans-serif;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    padding: 0.45rem 1rem;
    border-radius: 4px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s, transform 0.2s;
}

.toast.toast-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.toast-hide {
    opacity: 0;
    transform: translateX(-50%) translateY(0.4rem);
    transition: opacity 0.35s, transform 0.35s;
}
