body {
    font-family: Georgia, serif;
    font-size: 16px;
    line-height: 1.6;
    color: #141413;
    background-color: #F0EFEA;
    margin: 0;
    padding: 0 0 60px 0;
    transition: background-color 0.3s, color 0.3s;
}

html, body {
    overflow-x: hidden; /* Prevent horizontal scrollbar during transition */
}

.content-wrapper {
    max-width: 650px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

header {
    background-color: #F0EFEA;
    padding: 20px 0;
    margin-bottom: 20px;
    transition: background-color 0.3s;
}

header > div {
    max-width: 650px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    margin: 0;
    font-size: 20px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

header h1 a {
    text-decoration: none;
    color: inherit;
    font-weight: bold;
}

.toggle-switch {
    position: relative;
    width: 40px;
    height: 20px;
    flex-shrink: 0;
    margin-left: 1em;
}

.toggle-input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #F0EFEA;
    transition: .4s;
    border-radius: 34px;
    border: 1px solid #141413;
}

.toggle-slider {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 2px;
    bottom: 2px;
    background-color: #141413;
    transition: .4s;
    border-radius: 50%;
}

.toggle-input:checked + .toggle-label {
    background-color: #141413;
    border-color: #F0EFEA;
}

.toggle-input:checked + .toggle-label .toggle-slider {
    transform: translateX(20px);
    background-color: #F0EFEA;
}

h2, h3 {
    margin-top: 1em;
    margin-bottom: 0.5em;
    text-align: left;
    font-weight: bold;
}

h2 { 
    font-size: 18px; 
    margin-top: 0.5em;
}

h3 { font-size: 16px; }

.author-date {
    margin-top: 0.5em;
    margin-bottom: 1em;
    font-size: 0.9em;
    color: #666;
}

a {
    color: inherit;
    text-decoration: underline;
}

ul { padding-left: 20px; }

/* Table of Contents Styles */
#tocToggle {
    position: fixed;
    top: 20px;
    left: 15px;
    z-index: 1001;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #141413;
    padding: 0;
    outline: none;
}

.toc-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 250px;
    height: 100vh;
    background-color: #F0EFEA;
    overflow-y: auto;
    transition: transform 0.3s ease-in-out, background-color 0.3s ease, border-color 0.3s ease;
    padding: 20px 15px;
    box-sizing: border-box;
    z-index: 999;
    transform: translateX(-100%);
    border-right: 1px solid #F0EFEA;
}

.toc-container h3 {
    margin-top: 60px;
    padding: 20px 20px 15px;
    font-size: 16px;
    margin-bottom: 0;
    font-weight: bold;
}

#tocList {
    list-style-type: none;
    padding: 0 0px;
    margin-top: 0;
}

#tocList a {
    display: block;
    padding: 5px 0;
    text-decoration: none;
    color: inherit;
}

#tocList a:hover {
    text-decoration: underline;
}

#tocList a.active {
    font-weight: normal;
}

#tocList a.h3 {
    padding-left: 15px;
    font-size: 0.9em;
}

body.toc-visible .toc-container {
    transform: translateX(0);
}

/* Mobile TOC link */
.mobile-toc-link {
    display: none;
    margin-top: 10px;
    margin-bottom: 20px;
    font-weight: bold;
    color: #141413;
    text-decoration: underline;
    cursor: pointer;
}

/* Mobile TOC close button */
#tocCloseButton {
    display: none;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1002;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #141413;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    outline: none;
}

/* Responsive Styles */
@media (max-width: 768px) {
    body {
        font-size: 16px;
    }
    
    .content-wrapper, header > div {
        padding: 0 15px;
    }

    header h1 {
        font-size: 20px;
    }

    header {
        margin-bottom: 15px;
    }

    h2 {
        margin-top: 0.3em;
    }

    .author-date {
        font-size: 0.8em;
    }

    .mobile-toc-link {
        display: block;
    }
    
    .toc-container {
        width: 100%;
        padding-top: 60px;
    }
    
    #tocToggle {
        display: none;
    }

    .toc-container h3 {
        margin-top: 0;
    }

    body.toc-visible #tocCloseButton {
        display: block;
        opacity: 1;
    }
}

/* Larger screen styles */
@media (min-width: 769px) {
    #tocToggle {
        display: block;
    }
}

/* Dark Mode Styles */
body.dark-mode,
body.dark-mode header,
body.dark-mode .toc-container {
    color: #F0EFEA;
    background-color: #141413;
}

body.dark-mode #tocToggle,
body.dark-mode #tocCloseButton {
    color: #F0EFEA;
}

body.dark-mode .toggle-label {
    background-color: #141413;
    border-color: #F0EFEA;
}

body.dark-mode .toggle-slider {
    background-color: #F0EFEA;
}

body.dark-mode .toggle-input:checked + .toggle-label {
    background-color: #F0EFEA;
    border-color: #141413;
}

body.dark-mode .toggle-input:checked + .toggle-label .toggle-slider {
    background-color: #141413;
}

body.dark-mode .mobile-toc-link {
    color: #F0EFEA;
}

body.dark-mode .toc-container {
    border-right-color: #141413;
}

/* Ensure smooth transition for all properties */
body, .toc-container, #tocToggle, #tocCloseButton {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}
