:root {
    --bg-color: #fdfdfd;
    --text-color: #333;
    --link-color: #007bff;
    --border-color: #eee;
    --header-bg: #f8f9fa;
    --code-bg: #f6f8fa;
    --container-bg: #fff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    margin: 0 auto;
    padding: 20px;
    background: var(--container-bg);
}

header {
    display: flex;
    justify-content: center;
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 20px;
}

header a {
    margin-right: 20px;
}

main {
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: #0056b3;
    text-decoration: underline;
}

.content-list ul {
    list-style-type: none;
    padding-left: 0;
}

.content-list li {
    margin-bottom: 10px;
    font-size: 1.1em;
}

/* Content Layout for Sidebar TOC */
.content-layout {
    display: flex;
    gap: 40px;
}

.main-article {
    flex-grow: 1;
    min-width: 0; /* Allows content to shrink */
}

.main-article h2 {
    text-transform: capitalize;
}

/* Wrapper to constrain content to a readable width and center it */
.readable-width-wrapper {
    max-width: 900px;
    margin: 0 auto;
}

/* HTMX transitions for fade-in and fade-out */
#content {
    transition: opacity 200ms ease-in;
}
#content.htmx-swapping {
    opacity: 0;
    transition: opacity 200ms ease-out;
}
#content.htmx-settling {
    opacity: 0;
}

.toc {
    flex-shrink: 0;
    width: 200px;
    border-right: 1px solid var(--border-color);
    padding: 10px 20px;
    position: sticky;
    top: 20px;
    align-self: flex-start;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.toc ul {
    list-style-type: none;
    padding-left: 20px;
}

.toc-level-1 { font-weight: bold; }
.toc-level-2 { padding-left: 1em; }
.toc-level-3 { padding-left: 2em; }
.toc-level-4 { padding-left: 3em; }
.toc-level-5 { padding-left: 4em; }
.toc-level-6 { padding-left: 5em; }


.code-block-wrapper {
    position: relative;
    margin-bottom: 1em;
    background-color: var(--code-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.copy-code-button {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 8px;
    background-color: #e9ecef;
    border: 1px solid #ced4da;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
    opacity: 0;
    transition: opacity 0.2s, background-color 0.2s;
}

.copy-code-button:hover {
    background-color: #d8dfe4;
}

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

.code-block-wrapper pre {
    background-color: transparent !important;
    border: none !important;
    margin-bottom: 0 !important;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #0d1117;
        --text-color: #f0f6fc;
        --link-color: #4493f8;
        --border-color: #30363d;
        --header-bg: #161b22;
        --code-bg: #161b22;
        --container-bg: #0d1117;
    }

    .copy-code-button {
        background-color: #21262d;
        border-color: #30363d;
        color: #f0f6fc;
    }

    .copy-code-button:hover {
        background-color: #30363d;
        border-color: #8b949e;
    }
}
