body {
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #0b0d0b;
    background: #fafaf8;
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
    font-weight: 400;
}

header {
    border-bottom: 1px solid #878b8633;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
}

nav a {
    text-decoration: none;
    color: #0b0d0b;
    font-weight: 600;
    font-size: 1rem;
}

.nav-separator {
    margin: 0 0.5rem;
    color: #595959;
}

h1 {
    color: #0b0d0b;
    font-size: 2rem;
    line-height: 2.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

h2 {
    color: #2e3138;
    font-size: 1.5rem;
    line-height: 2rem;
    font-weight: 600;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

h3 {
    color: #0b0d0b;
    font-size: 1rem;
    line-height: 1.125rem;
    font-weight: 600;
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
}

p {
    margin-bottom: 1rem;
    line-height: 1.5;
}

a {
    color: #2563eb;
}

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

nav ul, .post-list {
    list-style: none;
    padding: 0;
}

ul {
    list-style: disc;
    padding-left: 2rem;
    margin-bottom: 1rem;
}

ol {
    list-style: decimal;
    padding-left: 2rem;
    margin-bottom: 1rem;
}

li {
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.post-meta {
    color: #595959;
    font-size: 0.8125rem;
    font-weight: 400;
}

.post-meta time {
    color: #595959;
}

.author {
    color: #595959;
    margin-left: 0.5rem;
}

code {
    font-family: "Berkeley Mono", ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.8125rem;
    background: #0b0d0b05;
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
}

pre {
    font-family: "Berkeley Mono", ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.8125rem;
    line-height: 1.25rem;
    background: #f1f1f3;
    padding: 1rem;
    border-radius: 0.375rem;
    overflow-x: auto;
    margin-bottom: 1rem;
}

pre code {
    background: transparent;
    padding: 0;
}

footer {
    border-top: 1px solid #878b8633;
    margin-top: 3rem;
    padding-top: 1rem;
    text-align: center;
    color: #595959;
}

.mermaid {
    text-align: center;
    margin: 1.5rem auto;
}

/* Add spacing for footnote references */
sup {
    margin-right: 0.25rem;
}

/* Blockquote styling for disclaimers and notes */
blockquote {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-radius: 0.375rem;
}

blockquote p {
    margin: 0;
    color: #92400e;
    font-weight: 500;
}

blockquote strong {
    color: #78350f;
}

/* Highlight footnotes when targeted via URL hash */
.footnote-ref:target,
.footnote-backref:target,
sup:target,
li:target {
    background-color: #fef3c7;
    border-radius: 0.25rem;
    animation: highlight-fade 3s ease-in-out;
}

@keyframes highlight-fade {
    0% {
        background-color: #fbbf24;
    }
    50% {
        background-color: #fef3c7;
    }
    100% {
        background-color: transparent;
    }
}

/* Code copy button */
.code-container {
    position: relative;
}

.copy-button {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.375rem;
    background-color: #2e3138;
    color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, background-color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.copy-button svg {
    width: 16px;
    height: 16px;
}

.code-container:hover .copy-button {
    opacity: 1;
}

.copy-button:hover {
    background-color: #1d1f24;
}

.copy-button:active {
    transform: scale(0.95);
}

.copy-button.copied {
    background-color: #22c55e;
}

/* Wrap button */
.wrap-button {
    position: absolute;
    top: 0.5rem;
    right: 3rem;
    padding: 0.375rem;
    background-color: #2e3138;
    color: #ffffff;
    border: none;
    border-radius: 0.25rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease-in-out, background-color 0.2s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wrap-button svg {
    width: 16px;
    height: 16px;
}

.code-container:hover .wrap-button {
    opacity: 1;
}

.wrap-button:hover {
    background-color: #1d1f24;
}

.wrap-button:active {
    transform: scale(0.95);
}

.wrap-button.active {
    background-color: #2563eb;
}

/* Wrapped code state */
pre.wrapped {
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Hugo line numbers table fix */
.highlight table {
    table-layout: fixed;  /* Critical: makes max-width work in cells */
    width: 100%;
    overflow-x: auto;
    display: block;
}

.highlight table td {
    padding: 0;
}

.highlight table td:first-child {
    /* Line numbers column */
    min-width: 2rem;
    padding-right: 1rem;
    text-align: right;
    user-select: none;
    color: #878b86;
}

.highlight table td:last-child {
    /* Code column */
    width: 100%;
    overflow-x: auto;
    max-width: 0;  /* Forces the cell to respect content constraints */
}

/* Constrain code container inside table cells */
.highlight td .code-container {
    max-width: calc(100vw - 150px);  /* Default: viewport - margins */
    width: 100%;
}

/* Medium screens */
@media (min-width: 1504px) {
    .highlight td .code-container {
        max-width: calc(1340px);  /* Body content width */
    }
}

/* Wide screens with TOC */
@media (min-width: 1600px) {
    .highlight td .code-container {
        max-width: calc(100vw - 280px - 100px - 6rem);  /* Viewport - TOC - line numbers - gaps */
    }
}


/* Heading anchor links */
h2, h3, h4, h5, h6 {
    position: relative;
}

.heading-anchor {
    position: absolute;
    left: -1.5rem;
    top: 50%;
    transform: translateY(-50%);
    color: #595959;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
    display: inline-flex;
    align-items: center;
    padding: 0.25rem;
}

.heading-anchor svg {
    width: 16px;
    height: 16px;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
h4:hover .heading-anchor,
h5:hover .heading-anchor,
h6:hover .heading-anchor,
.heading-anchor:hover {
    opacity: 1;
}

.heading-anchor:hover {
    color: #2563eb;
}

/* Table of Contents */
.content-wrapper {
    display: flex;
    gap: 3rem;
    position: relative;
}

article {
    flex: 1;
    max-width: 1440px;
    min-width: 0; /* Allow article to shrink when needed */
    width: 100%;
}

.toc-container {
    display: none;
}

/* Show TOC on wide screens */
@media (min-width: 1600px) {
    .toc-container {
        display: block;
        width: 280px;
        flex-shrink: 0;
    }
    
    .toc {
        position: sticky;
        top: 2rem;
        max-height: calc(100vh - 4rem);
        overflow-y: auto;
    }
}

h3.toc-title {
    font-size: 0.75rem;
    font-weight: 400;
    color: #595959;
    margin-bottom: 0.5rem;
    margin-top: 0;
    position: relative;
}

.toc-depth-hint {
    position: absolute;
    right: 0;
    font-size: 0.65rem;
    color: #d0d0d0;
    opacity: 0;
    transition: opacity 0.2s ease-in-out;
}

h3.toc-title:hover .toc-depth-hint {
    opacity: 1;
}

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

.toc-item {
    margin: 0;
}

.toc-link {
    display: block;
    padding: 0.25rem 0;
    color: #595959;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.5;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    transition: all 0.2s ease-in-out;
}

/* Indent based on heading level with subtle tree lines */
.toc-level-3 .toc-link { 
    padding-left: 2rem;
    position: relative;
}
.toc-level-3 .toc-link::before {
    content: "├─";
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #e5e5e5;
    font-size: 0.75rem;
    font-family: monospace;
}
.toc-level-4 .toc-link { 
    padding-left: 3.25rem;
    position: relative;
}
.toc-level-4 .toc-link::before {
    content: "├─";
    position: absolute;
    left: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #ebebeb;
    font-size: 0.75rem;
    font-family: monospace;
}
.toc-level-5 .toc-link { 
    padding-left: 4.5rem;
    position: relative;
}
.toc-level-5 .toc-link::before {
    content: "├─";
    position: absolute;
    left: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #f0f0f0;
    font-size: 0.75rem;
    font-family: monospace;
}
.toc-level-6 .toc-link { 
    padding-left: 5.75rem;
    position: relative;
}
.toc-level-6 .toc-link::before {
    content: "├─";
    position: absolute;
    left: 2.25rem;
    top: 50%;
    transform: translateY(-50%);
    color: #f5f5f5;
    font-size: 0.75rem;
    font-family: monospace;
}

.toc-link:hover {
    color: #2563eb;
}

.toc-link.active {
    color: #2563eb;
    border-left-color: #2563eb;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
}

/* Table styling */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5rem 0;
    font-size: 0.875rem;
    border: 1px solid #e5e7eb;
}

table thead tr {
    background-color: #fef2f2;
    border-bottom: 2px solid #d1d5db;
}

table thead th {
    padding: 0.375rem 1rem;
    text-align: left;
    font-weight: 600;
    color: #991b1b;
    border-right: 1px solid #e5e7eb;
}

table thead th:last-child {
    border-right: none;
}

table tbody tr {
    border-bottom: 1px solid #e5e7eb;
}

table tbody tr:nth-child(even) {
    background-color: #fafafa;
}

table tbody tr:nth-child(odd) {
    background-color: #ffffff;
}

table tbody tr:hover {
    background-color: #f3f4f6;
}

table tbody td {
    padding: 0.3125rem 1rem;
    color: #374151;
    border-right: 1px solid #e5e7eb;
}

table tbody td:last-child {
    border-right: none;
}

/* Make first column slightly emphasized */
table tbody td:first-child {
    font-weight: 500;
}