:root {
    --c-bg: #fff;
    --c-text: #1a1a1a;
    --c-text-muted: #6b7280;
    --c-link: #2563eb;
    --c-link-hover: #1d4ed8;
    --c-border: #e5e7eb;
    --c-code-bg: #f3f4f6;
    --c-header-bg: #fafafa;
    --c-tag-bg: #f0f0f0;
    --c-tag-text: #374151;
    --c-blockquote: #6b7280;
    --c-blockquote-border: #d1d5db;
    --font-sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'Cascadia Code', 'Fira Code', Menlo, monospace;
    --max-width: 42rem;
}
[data-theme="dark"] {
    --c-bg: #111827;
    --c-text: #e5e7eb;
    --c-text-muted: #9ca3af;
    --c-link: #60a5fa;
    --c-link-hover: #93bbfd;
    --c-border: #374151;
    --c-code-bg: #1f2937;
    --c-header-bg: #0f172a;
    --c-tag-bg: #1f2937;
    --c-tag-text: #d1d5db;
    --c-blockquote: #9ca3af;
    --c-blockquote-border: #4b5563;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--c-text);
    background: var(--c-bg);
    transition: color .2s, background .2s;
}
a { color: var(--c-link); text-decoration: none; }
a:hover { color: var(--c-link-hover); text-decoration: underline; }

/* Header */
.site-header {
    border-bottom: 1px solid var(--c-border);
    background: var(--c-header-bg);
    transition: background .2s, border-color .2s;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1.5rem;
    max-width: var(--max-width);
    margin: 0 auto;
}
.site-header .site-name {
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--c-text);
    text-decoration: none;
}
.site-header .site-name:hover { color: var(--c-link); text-decoration: none; }
.site-header nav ul { list-style: none; display: flex; gap: 1.25rem; }
.site-header nav a { font-size: .9375rem; }
.header-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.archive-link,
.feed-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .25rem .5rem;
    border: 1px solid var(--c-border);
    border-radius: .375rem;
    color: var(--c-text-muted);
    transition: border-color .2s, color .2s, background .2s;
    text-decoration: none;
}
.archive-link:hover {
    border-color: var(--c-link);
    color: var(--c-link);
    background: rgba(59, 130, 246, 0.1);
    text-decoration: none;
}
.feed-link:hover {
    border-color: #f26522;
    color: #f26522;
    background: rgba(242, 101, 34, 0.1);
    text-decoration: none;
}
.archive-link svg,
.feed-link svg {
    display: block;
}

.icon-btn {
    background: transparent;
    border: none;
    border-radius: .5rem;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    cursor: pointer;
    color: var(--c-text-muted);
    transition: background-color .2s, color .2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover {
    background-color: var(--c-tag-bg);
    color: var(--c-text);
}
.icon-btn svg {
    width: 1.125rem;
    height: 1.125rem;
}
.buttons {
    display: flex;
    align-items: center;
    gap: .5rem;
}

/* Main content */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 1.5rem; }
main { padding: 2.5rem 0 4rem; }
main .container > h1 { font-size: 1.75rem; font-weight: 700; margin-bottom: 1.5rem; line-height: 1.3; }

/* Collection header */
.collection-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}
.collection-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0;
}
.collection-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
}

/* Article / entry */
article h1 { font-size: 2rem; font-weight: 700; line-height: 1.25; margin-bottom: .5rem; }
.entry-meta { color: var(--c-text-muted); font-size: .9375rem; margin-bottom: 2rem; display: flex; gap: .75rem; flex-wrap: wrap; }
.entry-meta time, .entry-meta .author { display: inline; }
.content { font-size: 1.0625rem; line-height: 1.8; }
.content h2 { font-size: 1.5rem; font-weight: 600; margin: 2rem 0 .75rem; }
.content h3 { font-size: 1.25rem; font-weight: 600; margin: 1.75rem 0 .5rem; }
.content h4 { font-size: 1.0625rem; font-weight: 600; margin: 1.5rem 0 .5rem; }
.content p { margin-bottom: 1.25rem; }
.content ul, .content ol { margin: 0 0 1.25rem 1.5rem; }
.content li { margin-bottom: .25rem; }
.content blockquote {
    border-left: 3px solid var(--c-blockquote-border);
    padding: .5rem 0 .5rem 1.25rem;
    margin: 1.25rem 0;
    color: var(--c-blockquote);
    font-style: italic;
}
.content pre {
    background: var(--c-code-bg);
    border-radius: .5rem;
    padding: 1rem 1.25rem;
    overflow-x: auto;
    margin: 1.25rem 0;
    font-size: .875rem;
    line-height: 1.6;
    transition: background .2s;
}
.content pre[style] { background-color: var(--c-code-bg) !important; }
[data-theme="dark"] .content pre[style] span[style] { filter: invert(.85) hue-rotate(180deg); }
.content code { font-family: var(--font-mono); font-size: .9em; }
.content :not(pre) > code {
    background: var(--c-code-bg);
    padding: .15em .35em;
    border-radius: .25rem;
    transition: background .2s;
}
.content img { max-width: 100%; height: auto; border-radius: .5rem; margin: 1.25rem 0; }
.content a.tag-link {
    display: inline-block;
    background: var(--c-tag-bg);
    color: var(--c-tag-text);
    padding: .125rem .5rem;
    border-radius: .25rem;
    font-size: .9em;
    text-decoration: none;
    transition: background .2s, color .2s;
}
.content a.tag-link:hover {
    background: var(--c-link);
    color: #fff;
    text-decoration: none;
}
.content table { width: 100%; border-collapse: collapse; margin: 1.25rem 0; font-size: .9375rem; }
.content th, .content td { padding: .5rem .75rem; border: 1px solid var(--c-border); text-align: left; }
.content th { background: var(--c-code-bg); font-weight: 600; }
.content hr { border: none; border-top: 1px solid var(--c-border); margin: 2rem 0; }

/* Archive */
.archive-years {
    list-style: none;
    margin: 2rem 0;
}
.archive-years li {
    padding: .5rem 0;
}
.archive-years a {
    font-size: 1.125rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: .125rem .5rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: .25rem;
    margin-left: .5rem;
    text-transform: uppercase;
    letter-spacing: .025em;
}
.badge-draft {
    background: #fbbf24;
    color: #78350f;
}
.badge-future {
    background: #60a5fa;
    color: #1e3a8a;
}
.entry-meta .badge {
    margin-left: 0;
    margin-right: .5rem;
}

/* Entry list */
.entry-list { list-style: none; }
.entry-list li { padding: 1rem 0; border-bottom: 1px solid var(--c-border); }
.entry-list li:last-child { border-bottom: none; }
.entry-list a { font-weight: 600; font-size: 1.125rem; }
.entry-list time { display: block; color: var(--c-text-muted); font-size: .875rem; margin-top: .125rem; }
.entry-list p { color: var(--c-text-muted); font-size: .9375rem; margin-top: .375rem; }

/* Tag / term list */
.term-list { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; }
.term-list a {
    display: inline-block;
    background: var(--c-tag-bg);
    color: var(--c-tag-text);
    padding: .25rem .75rem;
    border-radius: 2rem;
    font-size: .875rem;
    transition: background .2s, color .2s;
}
.term-list a:hover { background: var(--c-link); color: #fff; text-decoration: none; }

/* Author */
.author-profile { display: flex; gap: 1.5rem; align-items: flex-start; margin-bottom: 2rem; }
.author-profile img { width: 5rem; height: 5rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.author-profile .author-info { flex: 1; }
.author-profile h1 { font-size: 1.75rem; margin-bottom: .25rem; }
.author-profile .author-links { color: var(--c-text-muted); font-size: .9375rem; }
.author-profile .author-links a { margin-right: 1rem; }
.author-profile .bio { margin-top: .75rem; }

/* Author index */
.author-grid { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 1rem; }
.author-grid li { display: flex; align-items: center; gap: .75rem; padding: .75rem; border: 1px solid var(--c-border); border-radius: .5rem; transition: border-color .2s; }
.author-grid li:hover { border-color: var(--c-link); }
.author-grid img { width: 2.5rem; height: 2.5rem; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.author-grid a { font-weight: 600; }

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--c-border);
    font-size: .9375rem;
}
.pagination span { color: var(--c-text-muted); }

/* Archive months */
.archive-months ul { list-style: none; display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.5rem; }
.archive-months a {
    display: inline-block;
    background: var(--c-tag-bg);
    color: var(--c-tag-text);
    padding: .25rem .75rem;
    border-radius: 2rem;
    font-size: .875rem;
    transition: background .2s, color .2s;
}
.archive-months a:hover { background: var(--c-link); color: #fff; text-decoration: none; }
.back-link { margin-bottom: 1.5rem; font-size: .9375rem; }

/* Footer */
.site-footer {
    border-top: 1px solid var(--c-border);
    padding: 1.5rem 0;
    color: var(--c-text-muted);
    font-size: .875rem;
    transition: border-color .2s;
}
.site-footer .container { text-align: center; }
.site-footer nav ul { list-style: none; display: flex; justify-content: center; gap: 1.25rem; }

/* 404 */
.error-page { text-align: center; padding: 4rem 0; }
.error-page h1 { font-size: 4rem; font-weight: 700; margin-bottom: .5rem; }
.error-page p { color: var(--c-text-muted); font-size: 1.125rem; margin-bottom: 1.5rem; }

/* TOC Sidebar */
.container:has(.article-with-sidebar) {
    max-width: calc(var(--max-width) + 14rem + 2.5rem);
}
.article-with-sidebar {
    display: grid;
    grid-template-columns: 14rem var(--max-width);
    gap: 2.5rem;
    align-items: start;
}
.toc-sidebar {
    position: sticky;
    top: 1.5rem;
    max-height: calc(100vh - 3rem);
    overflow-y: auto;
}
.toc-sidebar nav {
    font-size: .875rem;
    line-height: 1.5;
}
.toc-sidebar nav > ol {
    list-style: none;
    margin: 0;
    padding: 0;
    border-left: 1px solid var(--c-border);
}
.toc-sidebar li {
    margin: 0;
}
.toc-sidebar a {
    display: block;
    padding: .35rem .75rem;
    color: var(--c-text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    margin-left: -1px;
    transition: color .15s, border-color .15s;
}
.toc-sidebar a:hover {
    color: var(--c-link);
    text-decoration: none;
}
.toc-sidebar .toc-level-2 { padding-left: .75rem; }
.toc-sidebar .toc-level-3 { padding-left: 1.5rem; }
.toc-sidebar .toc-level-4 { padding-left: 2.25rem; }
.toc-sidebar .toc-level-5 { padding-left: 3rem; }
.toc-sidebar .toc-level-6 { padding-left: 3.75rem; }

/* Responsive: hide sidebar on narrow screens */
@media (max-width: 1024px) {
    .article-with-sidebar {
        grid-template-columns: 1fr;
    }
    .toc-sidebar {
        display: none;
    }
}
.image-zoom-overlay {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity .3s ease;
}
.image-zoom-overlay.active {
    display: flex;
    opacity: 1;
}
.image-zoom-content {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    cursor: zoom-out;
}
.image-zoom-close {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    background: none;
    border: none;
    color: #fff;
    font-size: 3rem;
    font-weight: 300;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: .7;
    transition: opacity .2s;
}
.image-zoom-close:hover {
    opacity: 1;
}
