:root {
    color-scheme: dark;
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    --accent: #3291ff;
    --border: #313131;
    --background: #0a0a0a;
    --code-bg: #1c1c1c;

    --font-sans: 'Tabular', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-mono: 'Tabular', 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    background-color: var(--background);
    color-scheme: dark;
}

body {
    font-family: var(--font-sans);
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--background);
    font-size: 14px;
    font-weight: 400;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body.home main {
    min-height: auto;
}

.container {
    max-width: 680px;
    margin: 0 auto;
    padding: 64px 20px;
}

.header {
    margin-bottom: 40px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.site-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.site-title a {
    color: var(--text-primary);
    text-decoration: none;
}

.site-description {
    color: var(--text-secondary);
    font-size: 16px;
    font-weight: 400;
}

nav {
    display: flex;
    gap: 24px;
}

nav a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 400;
    transition: color 0.15s ease;
}

nav a:hover {
    color: var(--text-primary);
}

nav a.active {
    color: var(--text-primary);
}

.prose {
    max-width: none;
    font-family: var(--font-sans);
    font-size: 14px;
}

.prose h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.2;
    color: var(--text-primary);
}

.prose h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 40px 0 16px 0;
    line-height: 1.3;
    color: var(--text-primary);
}

.prose h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 32px 0 12px 0;
    line-height: 1.3;
    color: var(--text-primary);
}

.prose p {
    margin-bottom: 20px;
    font-weight: 400;
    line-height: 1.7;
}

.prose ul,
.prose ol {
    margin-bottom: 20px;
    padding-left: 20px;
    list-style-type: disc;
}

.prose ol {
    list-style-type: decimal;
}

.prose li {
    margin-bottom: 8px;
    display: list-item;
}

.prose blockquote {
    border-left: 3px solid var(--border);
    padding-left: 20px;
    margin: 20px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.prose code {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 400;
}

.prose pre {
    background: var(--code-bg);
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 20px 0;
    font-size: 12px;
    line-height: 1.5;
}

.prose pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.prose img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 20px 0;
}

.prose a {
    color: var(--accent);
    text-decoration: none;
}

.prose a:hover {
    text-decoration: underline;
}

.prose hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 2.5em 0;
}

.prose table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
    font-size: 0.95em;
}

.prose th,
.prose td {
    padding: 8px 14px;
    border: 1px solid var(--border);
    text-align: left;
}

.prose th {
    background: var(--code-bg);
    color: var(--text-primary);
}

.prose strong, .prose b {
    color: var(--text-primary);
    font-weight: 600;
}

.post-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.post-list-item {
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}

.post-list-item:first-child {
    border-top: 1px solid var(--border);
}

.post-meta {
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 400;
}

.post-list-item .post-meta {
    padding-top: 16px;
    margin-bottom: 4px;
}

.post-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 4px;
}

.post-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.post-title a:hover {
    color: var(--accent);
}

.post-excerpt {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    font-weight: 400;
    padding-bottom: 16px;
    margin-top: 4px;
}

.pagination {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    margin-top: 32px;
    font-size: 14px;
}

.pagination-prev {
    justify-self: start;
}

.pagination-next {
    justify-self: end;
}

.pagination-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.pagination-link:hover {
    color: var(--text-primary);
}

.pagination-info {
    color: var(--text-tertiary);
    font-size: 12px;
    text-align: center;
}

.back-link {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 40px;
    display: inline-block;
    text-decoration: none;
    transition: color 0.15s ease;
}

.back-link:hover {
    color: var(--text-primary);
}

.post-content,
.page-content {
    padding: 0;
    margin: 0;
}

.post-content h1 {
    font-size: 24px;
    font-weight: 600;
    margin: 16px 0 8px;
    line-height: 1.2;
    color: var(--text-primary);
}

.post-content h2 {
    font-size: 18px;
    font-weight: 600;
    margin: 40px 0 16px 0;
    line-height: 1.3;
    color: var(--text-primary);
}

.post-content h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 32px 0 12px 0;
    line-height: 1.3;
    color: var(--text-primary);
}

.post-content h4,
.post-content h5,
.post-content h6 {
    font-size: 14px;
    font-weight: 600;
    margin: 24px 0 8px;
    line-height: 1.3;
    color: var(--text-primary);
}

.post-content p {
    margin-bottom: 20px;
    font-weight: 400;
    line-height: 1.75;
}

.post-content ul,
.post-content ol {
    margin-bottom: 20px;
    padding-left: 20px;
}

.post-content li {
    margin-bottom: 8px;
}

.post-content blockquote {
    border-left: 3px solid var(--border);
    padding-left: 20px;
    margin: 20px 0;
    color: var(--text-secondary);
    font-style: italic;
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.86em;
    background: var(--code-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

.post-content pre {
    background: var(--code-bg);
    padding: 20px;
    border-radius: 6px;
    overflow-x: auto;
    margin: 20px 0;
    font-size: 12px;
    line-height: 1.5;
}

.post-content pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 1em;
}

.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 20px 0;
}

.post-content a {
    color: var(--accent);
    text-decoration: none;
}

.post-content a:hover {
    text-decoration: underline;
}

.post-content hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 2.5em 0;
}

.post-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
    font-size: 0.95em;
}

.post-content th,
.post-content td {
    padding: 8px 14px;
    border: 1px solid var(--border);
    text-align: left;
}

.post-content th {
    background: var(--code-bg);
    color: var(--text-primary);
}

.reading-time {
    color: var(--text-tertiary);
}

.post-toc {
    display: none;
}

.post-toc__label {
    margin: 0 0 0.65rem;
    padding-left: 0.85rem;
    font-family: var(--font-mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.post-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.post-toc__item {
    margin: 0;
}

.post-toc a {
    display: block;
    padding: 0.28rem 0 0.28rem 0.85rem;
    border-left: 2px solid var(--border);
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: 0.78rem;
    line-height: 1.45;
    transition: color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
}

.post-toc__item.lvl-3 a {
    padding-left: 1.7rem;
    font-size: 0.74rem;
}

.post-toc a:hover {
    color: var(--text-primary);
}

.post-toc a.is-active {
    color: var(--text-primary);
    border-left-color: var(--text-primary);
}

@media (min-width: 1200px) {
    .post-toc {
        display: block;
        position: fixed;
        top: 7rem;
        right: calc(50% + 372px);
        width: 190px;
        max-height: calc(100vh - 10rem);
        overflow-y: auto;
        margin: 0;
        padding: 0;
        border: 0;
    }
}

.post-content h2[id],
.post-content h3[id] {
    scroll-margin-top: 1.5rem;
}

.code-block {
    margin: 1.5em 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--code-bg);
}

.code-block__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 7px 8px 7px 14px;
    background: #151515;
    border-bottom: 1px solid var(--border);
}

.code-block__lang {
    font-family: var(--font-mono);
    font-size: 0.72em;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    user-select: none;
}

.code-block pre {
    margin: 0;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.6;
    background: transparent;
}

.code-block pre code,
.code-block pre code.hljs {
    display: block;
    padding: 14px 16px;
    background: transparent;
    color: inherit;
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: 1em;
    -moz-tab-size: 4;
    tab-size: 4;
}

.copy-btn {
    flex: 0 0 auto;
    padding: 4px 12px;
    font-size: 0.74em;
    font-family: var(--font-mono);
    font-weight: 700;
    letter-spacing: 0.03em;
    line-height: 1.4;
    background: transparent;
    color: var(--text-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.copy-btn:hover {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.copy-btn.is-copied {
    background: #2ea043;
    color: #fff;
    border-color: #2ea043;
}

.post-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 1rem;
    margin: 2rem 0;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.post-nav a {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.post-nav a:hover {
    color: var(--text-primary);
}

.post-nav-next {
    text-align: right;
}

.related-posts {
    margin-top: 2rem;
}

.related-posts h3 {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    text-transform: lowercase;
    color: var(--text-tertiary);
    font-weight: 400;
}

.related-posts ul {
    list-style: none;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.related-posts li {
    margin-bottom: 0.4rem;
}

.related-posts a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.related-posts a:hover {
    color: var(--text-primary);
}

.upvote-button {
    padding: 0;
    margin: 0;
    border: 0;
    background-color: inherit;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.upvote-button.upvoted {
    color: salmon;
}

.upvote-count {
    margin-top: -3px;
}

.error-page {
    padding: 2rem 0;
}

.error-hero {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.75rem;
}

.error-code {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 2.75rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.error-sep {
    width: 1px;
    align-self: stretch;
    min-height: 2.5rem;
    background: var(--border);
}

.error-text {
    margin: 0;
    font-size: 1rem;
    color: var(--text-primary);
}

.error-lead {
    margin: 0 0 2.25rem;
    color: var(--text-tertiary);
}

.error-suggest-label {
    margin: 0 0 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.error-suggest {
    list-style: none;
    margin: 0 0 2.25rem;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

.error-suggest li {
    margin: 0;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border);
}

.error-suggest li:last-child {
    border-bottom: 1px solid var(--border);
}

.error-suggest a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.error-suggest a:hover {
    color: var(--text-primary);
}

.error-actions {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.error-actions a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.15s ease;
}

.error-actions a:hover {
    color: var(--text-primary);
}

.blog-posts {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.blog-posts li {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    margin: 0;
    padding: 0.4rem 0;
}

.blog-posts li > span {
    color: var(--text-tertiary);
    font-size: 0.75rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.blog-posts li a {
    color: var(--text-secondary);
    flex-grow: 1;
    min-width: 0;
    text-decoration: none;
    transition: color 0.15s ease;
}

.blog-posts li a:hover {
    color: var(--text-primary);
}

@media (max-width: 600px) {
    .error-code {
        font-size: 2.25rem;
    }
}

@media (min-width: 768px) {
    .container {
        padding-top: 80px;
    }

    .header {
        margin-bottom: 80px;
    }
}

@media (max-width: 640px) {
    .prose h1,
    .post-content h1 {
        font-size: 24px;
    }

    .prose h2,
    .post-content h2 {
        font-size: 20px;
    }

    .site-title {
        font-size: 22px;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 40px 20px;
    }
}

@view-transition {
    navigation: auto;
}

header {
    view-transition-name: site-header;
}

::view-transition-old(root) {
    animation: vt-fade-out 200ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

::view-transition-new(root) {
    animation: vt-fade-in 300ms cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes vt-fade-out {
    to {
        opacity: 0;
        transform: translateY(-8px);
    }
}

@keyframes vt-fade-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
}

::view-transition-group(*) {
    animation-duration: 320ms;
    animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
    ::view-transition-group(*),
    ::view-transition-old(*),
    ::view-transition-new(*) {
        animation: none !important;
    }
}
