html {
    font-family: "Cormorant Garamond", serif;
    font-weight: 400;
    font-style: normal;
    font-variant-numeric: lining-nums;
    scroll-behavior: smooth;
}

body {
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 105px;
    width: 80%;
    max-width: 800px;
    background-color: white;
    font-variant-numeric: lining-nums;
}

/* Lower threshold - below this width, use more space */
@media (max-width: 1000px) {
    body {
        width: 88%;
    }
}

a:link {
    color: #801f1f;
    font-weight: inherit;
    text-decoration: inherit;
}

a:visited {
    color: #801f1f;
    font-weight: inherit;
    text-decoration: inherit;
}

.icon {
    margin-right: 10px;
    color: #801f1f;
    width: 24px;
    height: 24px;
}

.profile-links {
    display: flex;
    align-items: center;
    margin: 10px 0;
}

header {
    background-color: white;
    color: black;
    margin-left: auto;
    margin-right: auto;
    padding: 7%;
    padding-top: 47px;
    padding-bottom: 21px;
}

header a {
    text-decoration: none;
}

/* Navigation styles */
nav {
    margin-top: 10px;
    font-size: 1.2em;
    color: #666;
}

nav a {
    text-decoration: none;
    color: #801f1f;
}

nav a:hover {
    text-decoration: underline;
}

/* Notes page styles */
.notes-container {
    padding: 0 7%;
    max-width: 100%;
    margin-top: 30px;
}

.note-entry {
    margin-bottom: 50px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
}

.note-entry:last-child {
    border-bottom: none;
}

.note-title {
    font-size: 1.7em;
    margin-bottom: 8px;
    font-weight: 400;
    line-height: 1.1;
}

.note-title a {
    text-decoration: none;
    color: #801f1f;
}

.note-title a:hover {
    text-decoration: underline;
}

.note-date {
    font-size: 1em;
    color: #666;
    margin-bottom: 15px;
    font-style: italic;
}

.note-abstract {
    font-size: 1.1em;
    line-height: 1.3;
    color: #333;
    margin: 0;
    text-align: justify;
}

/* Individual note page styles */
.note-container {
    padding: 0 7%;
    max-width: 100%;
}

/* LaTeX-style note formatting */
.note-header {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #ddd;
}

.note-header .note-title {
    font-size: 2.4em;
    margin-bottom: 20px;
    color: black;
    font-weight: 400;
    line-height: 1.1;
}

.note-header .note-meta {
    margin: 0;
}

.note-header .author {
    font-size: 1.2em;
    margin-bottom: 8px;
    font-weight: 400;
}

.note-header .date {
    font-size: 1em;
    color: #666;
    font-style: italic;
    margin: 0;
}

/* Abstract section */
.abstract {
    margin-bottom: 40px;
    padding: 25px;
    background-color: #fafafa;
    border-left: 4px solid #801f1f;
}

.abstract h2 {
    font-size: 1.4em;
    margin-top: 0;
    margin-bottom: 15px;
    color: black;
    font-weight: 600;
    font-variant: small-caps;
    letter-spacing: 1px;
}

.abstract p {
    font-size: 1.1em;
    line-height: 1.3;
    margin: 0;
    text-align: justify;
}

/* Table of Contents styles */
.table-of-contents {
    position: fixed;
    left: calc((100vw - 800px) / 2 - 200px);
    top: 68px;
    bottom: 20px;
    width: 200px;
    height: auto;
    overflow-y: auto;
    padding: 20px 15px;
    background-color: white;
    z-index: 100;
}

.table-of-contents h2 {
    font-size: 1.2em;
    margin-top: 0;
    margin-bottom: 15px;
    color: black;
    font-weight: 600;
    padding-bottom: 8px;
    text-align: left;
}

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

.toc-item {
    margin-bottom: 6px;
    line-height: 1.3;
}

.toc-item.subsection {
    margin-left: 15px;
    margin-bottom: 4px;
}

.toc-link {
    color: #666 !important;
    text-decoration: none;
    font-size: 1em;
    font-weight: 400;
    transition: all 0.2s ease;
    display: block;
    padding: 3px 0;
    border-left: 2px solid transparent;
    padding-left: 8px;
}

.toc-link:hover {
    color: #801f1f;
    border-left-color: #801f1f;
    background-color: #f9f9f9;
}

.toc-link:visited {
    color: #666;
}

.toc-link.active {
    color: #801f1f;
    border-left-color: #801f1f;
    background-color: #f9f9f9;
}

.toc-number {
    font-weight: inherit;
    margin-right: 6px;
}

/* Hide TOC on smaller screens */
@media (max-width: 1250px) {
    .table-of-contents {
        display: none;
    }
}

/* Note content */
.note-content {
    counter-reset: equation;
    font-size: 1.1em;
    line-height: 1.3;
    color: #333;
    text-align: justify;
}

.note-content h2 {
    font-size: 1.7em;
    margin-top: 50px;
    margin-bottom: 20px;
    color: black;
    font-weight: 600;
    border-bottom: 1px solid #eee;
    padding-bottom: 8px;
    scroll-margin-top: 20px;
}

.note-content h3 {
    font-size: 1.4em;
    margin-top: 35px;
    margin-bottom: 15px;
    color: black;
    font-weight: 500;
    scroll-margin-top: 20px;
}

.note-content p {
    margin-bottom: 20px;
    text-indent: 0;
}

.note-content p:first-child {
    text-indent: 0;
}

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

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

/* Mathematical equations */
.equation {
    text-align: center;
    margin: 30px 0;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 4px;
    position: relative;
    counter-increment: equation;
    /* Add horizontal scrolling for mobile */
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    /* Add subtle scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #ccc #f9f9f9;
}

/* Webkit scrollbar styling for better appearance */
.equation::-webkit-scrollbar {
    height: 8px;
}

.equation::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.equation::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.equation::-webkit-scrollbar-thumb:hover {
    background: #bbb;
}

.equation::after {
    content: "(" counter(equation) ")";
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.1em;
    color: #666;
    font-family: "Cormorant Garamond", serif;
    /* Ensure equation numbers stay visible */
    background-color: #f9f9f9;
    padding-left: 10px;
}

/* KaTeX math font adjustments */
.katex {
    font-size: 1em !important;
    font-weight: 400 !important;
    /* Ensure inline math doesn't break on mobile */
    display: inline-block;
    max-width: 100%;
}

.katex-display {
    font-size: 1.05em !important;
    /* Allow display math to scroll horizontally */
    overflow-x: auto;
    overflow-y: hidden;
    margin: 1em 0;
}

/* Prevent all superscripts from affecting line height */
sup {
    line-height: 0;
    position: relative;
    vertical-align: baseline;
    top: -0.5em;
    font-size: 0.75em;
}

/* Citations */
.citation {
    color: #801f1f;
    font-weight: 500;
}

/* References section */
.references {
    margin-top: 20px;
    padding-top: 0;
}

.note-content .references p {
    font-size: 1em;
    line-height: 1.3;
    margin-bottom: 15px;
    text-indent: -2em !important;
    padding-left: 2em;
}

.references em {
    font-style: italic;
}

.references strong {
    font-weight: 600;
}

/* Footnotes */
.footnotes {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #ddd;
    font-size: 0.95em;
}

.footnotes h3 {
    font-size: 1.3em;
    margin-bottom: 20px;
    color: black;
    font-weight: 600;
}

.footnote {
    margin-bottom: 15px;
    text-indent: 0 !important;
    line-height: 1.3 !important;
}

.footnote sup {
    margin-right: 8px;
    color: #801f1f;
    font-weight: 500;
}

.footnote-ref {
    color: #801f1f;
    text-decoration: none;
    font-weight: 500;
}

.footnote-ref:hover {
    text-decoration: underline;
}

.footnote-back {
    color: #801f1f;
    text-decoration: none;
    margin-left: 5px;
    font-weight: 500;
}

.footnote-back:hover {
    text-decoration: underline;
}

/* Ensure math in footnotes doesn't affect line height */
.footnote .katex {
    line-height: 1 !important;
    vertical-align: baseline !important;
}

.footnote .katex-display {
    margin: 0.5em 0 !important;
    line-height: 1 !important;
}

.back-link {
    display: inline-block;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eee;
    text-decoration: none;
    color: #801f1f;
}

.back-link:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    body {
        width: 90%;
        margin-bottom: 50px;
    }
    
    header {
        padding: 10%;
        padding-top: 30px;
        padding-bottom: 15px;
    }
    
    .notes-container,
    .note-container {
        padding: 0 10%;
    }
    
    .notes-container h1 {
        font-size: 2.2em;
    }
    
    .note-title {
        font-size: 1.7em;
    }
    
    .note-header .note-title {
        font-size: 2.1em;
    }
    
    .note-content {
        font-size: 1.1em;
    }
    
    /* Additional mobile-specific equation handling */
    .equation {
        margin: 20px 0;
        padding: 15px;
        /* Smaller padding on mobile for more content space */
        padding-right: 60px; /* Make room for equation number */
    }
    
    .equation::after {
        right: 15px;
        font-size: 1em;
        padding-left: 8px;
    }
    
    /* Ensure KaTeX display math is scrollable on mobile */
    .katex-display {
        margin: 0.5em 0;
        padding: 0.5em 0;
    }
}

@media (max-width: 480px) {
    body {
        width: 95%;
    }
    
    header {
        padding: 10%;
        padding-top: 20px;
        padding-bottom: 10px;
    }
    
    .notes-container,
    .note-container {
        padding: 0 10%;
    }
    
    .notes-container h1 {
        font-size: 2em;
    }
    
    .note-title {
        font-size: 1.5em;
    }
    
    .note-header .note-title {
        font-size: 1.8em;
    }
    
    .equation {
        padding: 12px;
        padding-right: 50px;
        margin: 15px 0;
    }
    
    .equation::after {
        right: 12px;
        font-size: 0.9em;
    }
}