:root {
    --c-bg: #fff;
    --c-text: #1a1a1a;
    --c-text-muted: #6b7280;
    --c-link: #2563eb;
    --c-link-hover: #1d4ed8;
    --c-border: #e5e7eb;
    --c-border-strong: #d1d5db;
    --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;
    --page-gutter: clamp(1rem, 4vw, 1.5rem);
    --header-control-size: 2.75rem;
}
[data-theme="dark"] {
    --c-bg: #111827;
    --c-text: #e5e7eb;
    --c-text-muted: #9ca3af;
    --c-link: #60a5fa;
    --c-link-hover: #93bbfd;
    --c-border: #374151;
    --c-border-strong: #4b5563;
    --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%;
    scrollbar-gutter: stable;
}
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: grid;
    grid-template-areas: "brand nav actions";
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 1.5rem;
    min-height: calc(var(--header-control-size) + 1.5rem);
    width: fit-content;
    min-width: min(100%, var(--max-width));
    max-width: calc(100% - (var(--page-gutter) * 2));
    padding: .75rem var(--page-gutter);
    margin: 0 auto;
}
.site-header .site-name {
    grid-area: brand;
    justify-self: start;
    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 {
    grid-area: nav;
    justify-self: center;
    min-height: var(--header-control-size);
    display: flex;
    align-items: center;
}
.site-header nav ul { list-style: none; display: flex; align-items: center; gap: 1.25rem; flex-wrap: nowrap; }
.site-header nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--header-control-size);
    padding: 0 .125rem;
    border-radius: .5rem;
    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: var(--header-control-size);
    height: var(--header-control-size);
    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 {
    grid-area: actions;
    display: flex;
    align-items: center;
    gap: .5rem;
    justify-self: end;
    flex-wrap: nowrap;
}
.ui-language-control {
    position: relative;
    display: inline-flex;
    align-items: center;
    height: var(--header-control-size);
}
.ui-language-control::after {
    content: "";
    position: absolute;
    top: 50%;
    right: .9rem;
    width: .45rem;
    height: .45rem;
    border-right: 1.5px solid var(--c-text-muted);
    border-bottom: 1.5px solid var(--c-text-muted);
    transform: translateY(-62%) rotate(45deg);
    pointer-events: none;
    transition: border-color .2s;
}
.ui-language-selector {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border: 1px solid var(--c-border);
    border-radius: .5rem;
    background: var(--c-bg);
    color: var(--c-text-muted);
    font: inherit;
    font-size: .875rem;
    line-height: 1.2;
    height: var(--header-control-size);
    padding: .7rem 2.1rem .7rem .8rem;
    transition: border-color .2s, color .2s, background-color .2s;
    cursor: pointer;
}
.ui-language-selector:hover,
.ui-language-selector:focus {
    border-color: var(--c-border-strong);
    color: var(--c-text);
    outline: none;
}
.ui-language-control:hover::after,
.ui-language-control:focus-within::after {
    border-color: var(--c-text);
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Main content */
.container { max-width: var(--max-width); margin: 0 auto; padding: 0 var(--page-gutter); }
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 a {
    overflow-wrap: anywhere;
    word-break: break-word;
}
.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; }
.entry-footer {
    margin-top: 2rem;
}
.entry-tags,
.entry-categories {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}
a.tag-link {
    display: inline-flex;
    align-items: center;
    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 {
    margin: 0 .25rem .5rem 0;
}
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;
}

/* Translations */
.translations { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--c-border); }
.translations h2 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.translations ul { list-style: none; display: flex; flex-wrap: wrap; gap: .75rem; }
.translations li { font-size: .9375rem; }

/* Related posts */
.related { margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid var(--c-border); }
.related h2 { font-size: 1.125rem; font-weight: 600; margin-bottom: .75rem; }
.related ul { list-style: none; }
.related li { padding: .5rem 0; }
.related a { font-weight: 500; }
.related time { display: block; color: var(--c-text-muted); font-size: .8125rem; margin-top: .125rem; }

/* 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;
    position: relative;
    left: calc((-14rem - 2.5rem) / 2);
}
.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: 860px) {
    .site-header .container {
        gap: 1rem;
    }

    .site-header nav ul {
        gap: .875rem;
    }

    .site-header .container {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "brand actions"
            "nav nav";
    }

    .site-header nav {
        justify-self: stretch;
    }

    .site-header nav ul {
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: .35rem .75rem;
    }

    .buttons {
        justify-content: flex-end;
    }

    .article-with-sidebar {
        grid-template-columns: 1fr;
        left: 0;
    }
    .toc-sidebar {
        display: none;
    }
}

@media (max-width: 480px) {
    article h1 {
        font-size: clamp(1.875rem, 8vw, 2rem);
        line-height: 1.15;
    }

    .site-header nav a {
        padding: .5rem .75rem;
    }
}

@media (max-width: 420px) {
    .site-header .container {
        grid-template-columns: 1fr;
        grid-template-areas:
            "brand"
            "nav"
            "actions";
        gap: .5rem;
    }

    .site-header .site-name,
    .site-header nav,
    .buttons {
        justify-self: stretch;
    }

    .buttons {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}
.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;
}
