body {
    font-family: "Charter", "Bitstream Charter", "Sitka Text", Cambria, serif;
    line-height: 1.7;
    color: #2c3e50;
}

h1, h2, h3, h4 {
    font-family: "Palatino", "Palatino Linotype", "Book Antiqua", Georgia, serif;
    font-weight: 500; 
    color: #1a252f;
    margin-top: 2em;
    margin-bottom: 0.8em;
    letter-spacing: 0.01em;  
}

h1 {
    font-size: 2.2em;
    border-bottom: 1.5px solid #1a252f;  
    padding-bottom: 0.3em;
}

h2 {
    font-size: 1.6em;
    margin-top: 1.8em;
    font-weight: 500;
}

h3 {
    font-weight: 500;
}

.katex { 
    font-size: 1.15em;
    font-weight: 400;
    line-height: 1.2;
    font-family: "Latin Modern Math", "STIX Two Math", "KaTeX_Main", serif;
}

.katex .mrel {
    /* Relations like \to, \in */
    margin: 0 0.1em;
}

.katex .mbin {
    /* Binary operators like +, - */
    margin: 0 0.25em;
}

.katex .msup, .katex .msub, .katex .mfrac, .katex .msqrt {
    vertical-align: middle;
}

.katex-display {
    margin: 1.8em 0;
    padding: 0.5em 0;
    line-height: 1.3;
    text-align: center;
}

.callout-note {
    border: 1.5px solid #b0bec5;
    background-color: #f8f9fa;
    padding: 1.2em 1.5em;
    margin: 2em 0;
    border-radius: 0;
    box-shadow: none;
}

.callout-note .callout-header {
    font-family: "Palatino", Georgia, serif;
    font-weight: 400 !important;
    font-size: 1.05em;
    font-style: italic;
}

.callout-note .callout-title {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-note .callout-title-container {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-note.callout-style-default > .callout-header {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-note .callout-body {
    margin-top: 0.8em;
}

.callout-important {
    border: 1.5px solid #90b4d2 !important;
    border-left: 4px solid #5a8bb8;
    background-color: #f8fafb;
    padding: 1.2em 1.5em;
    margin: 2em 0;
    border-radius: 0;
}

.callout-important .callout-header {
    font-family: "Palatino", Georgia, serif;
    font-weight: 400 !important;
    font-style: italic;
    color: #4a5568;
}

.callout-important .callout-title {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-important .callout-title-container {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-important.callout-style-default > .callout-header {
    font-weight: 400 !important;
    font-style: italic;
}


.callout-tip {
    border: 1px solid #d0d4d9;
    background-color: #f9fafb;
    padding: 1em 1.3em;
    margin: 1.5em 0;
    border-radius: 0;
}

.callout-tip .callout-header {
    font-family: "Palatino", Georgia, serif;
    font-style: italic;
    color: #4a5568;
    font-weight: 400 !important;
}

.callout-tip .callout-title {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-tip .callout-title-container {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-tip.callout-style-default > .callout-header {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-tip .callout-body {
    margin-top: 0.8em;
}

.callout-warning {
    border: 1px solid #e2b778;
    border-left: 3px solid #d69e2e;
    background-color: #fffdf8;
    padding: 1.2em 1.5em;
    margin: 2em 0;
    border-radius: 0;
}

.callout-warning .callout-header {
    font-family: "Palatino", Georgia, serif;
    font-weight: 400 !important;
    font-style: italic;
    color: #4a5568;
}

.callout-warning .callout-title {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-warning .callout-title-container {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-warning.callout-style-default > .callout-header {
    font-weight: 400 !important;
    font-style: italic;
}

.callout-icon {
    display: none;
}

.callout-body {
    transition: none !important;
}







/* Definition blocks - regular text, blue accent */
div[id^="def-"] {
    border: 1px solid #d0d9e5;
    border-left: 5px solid #3f77e7;
    background-color: transparent;
    padding: 1.2em 1.5em;
    margin: 2em 0;
    border-radius: 0;
    box-shadow: none;
}

div[id^="def-"] > h3, div[id^="def-"] > h2 {
    font-family: "Palatino", Georgia, serif !important;
    font-weight: 400 !important;
    font-size: 1.05em !important;
    font-style: italic !important;
    margin-top: 0 !important;
    margin-bottom: 0.8em !important;
    color: #2c3e50 !important;
}

/* Theorem blocks - italic text, different accent */
div[id^="thm-"], div[id^="cor-"], div[id^="lem-"], div[id^="prop-"] {
    border: 1px solid #d0d9e5;
    border-left: 5px solid #f7d14b;
    background-color: transparent;
    padding: 1.2em 1.5em;
    margin: 2em 0;
    border-radius: 0;
    box-shadow: none;
    font-style: italic;
}

div[id^="thm-"] > h3, div[id^="thm-"] > h2,
div[id^="cor-"] > h3, div[id^="cor-"] > h2,
div[id^="lem-"] > h3, div[id^="lem-"] > h2,
div[id^="prop-"] > h3, div[id^="prop-"] > h2 {
    font-family: "Palatino", Georgia, serif !important;
    font-weight: 400 !important;
    font-size: 1.05em !important;
    font-style: italic !important;
    margin-top: 0 !important;
    margin-bottom: 0.8em !important;
    color: #2c3e50 !important;
}


figure {
    margin: 2.5em auto;
    text-align: center;
    max-width: 90%;
}

figure img {
    border: 1px solid #e2e8f0;
    border-radius: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    max-width: 100%;
}

figcaption {
    margin-top: 1em;
    font-style: italic;
    color: #5a6570;
    font-size: 0.95em;
    font-family: "Palatino", Georgia, serif;
}

.sourceCode {
    background-color: #f8f9fa;
    border: 1px solid #e1e4e8;
    border-left: 3px solid #6c757d;
    border-radius: 0;
    padding: 1em;
    font-family: "Fira Code", "Consolas", "Monaco", monospace;
    font-size: 0.9em;
}

pre {
    margin: 1.5em 0;
}

code {
    font-family: "Fira Code", "Consolas", monospace;
    font-size: 0.92em;
    background-color: #f1f3f5;
    padding: 0.15em 0.4em;
    border-radius: 2px;
}

.math.display {
    overflow-x: auto;
    overflow-y: hidden;
}

em {
    font-style: italic;
    font-weight: 400;
}

strong {
    font-weight: 500; 
    color: #1a252f;
}

blockquote {
    border-left: 3px solid #cbd5e0;
    padding-left: 1.5em;
    margin: 1.5em 0;
    color: #4a5568;
    font-style: italic;
    background-color: #f7fafc;
    padding: 1em 1.5em;
}

ul, ol {
    padding-left: 2em;
    margin: 1em 0;
}

li {
    margin: 0.5em 0;
}

table {
    border-collapse: collapse;
    margin: 2em auto;
    border-top: 2px solid #1a252f;
    border-bottom: 2px solid #1a252f;
}

thead {
    border-bottom: 1px solid #1a252f;
}

th {
    padding: 0.8em 1.2em;
    text-align: left;
    font-weight: 500;  
    font-family: "Palatino", Georgia, serif;
}

td {
    padding: 0.6em 1.2em;
    border-bottom: 1px solid #e2e8f0;
}

tbody tr:last-child td {
    border-bottom: none;
}

hr {
    border: none;
    border-top: 1px solid #cbd5e0;
    margin: 3em 0;
}

a {
    color: #2c5282;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-bottom 0.2s;
}

a:hover {
    border-bottom: 1px solid #2c5282;
}

.quarto-title {
    margin-bottom: 2em;
}

.quarto-title-block {
    border-bottom: 1.5px solid #1a252f;  
    padding-bottom: 1em;
    margin-bottom: 2em;
}

#TOC {
    font-family: "Palatino", Georgia, serif;
    font-size: 0.95em;
}

#TOC .active {
    font-weight: 500;  
    color: #1a252f;
}

.boxed {
    border: 1.5px solid #1a252f;  
    padding: 1em;
    margin: 1.5em 0;
    text-align: center;
}

@media print {
    body {
        font-size: 11pt;
    }
    
    .callout-note,
    .callout-important,
    .callout-tip,
    .callout-warning {
        page-break-inside: avoid;
    }
}

/* Mobile styles to match desktop */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* Match desktop base size */
        line-height: 1.7;
    }
    
    h1 {
        font-size: 2.2em;
    }
    
    h2 {
        font-size: 1.6em;
    }
    
    .katex {
        font-size: 1.15em;
    }
    
    /* Force sidebar to show like desktop (if applicable) */
    .quarto-sidebar {
        display: block !important;
        position: static !important;
        width: 250px !important;
    }
    
    .quarto-layout-content {
        margin-left: 250px !important;
    }
    
    /* Ensure containers don't shrink */
    .container, .container-fluid {
        max-width: none !important;
        width: 100% !important;
    }
}

/* Dark Mode Styles */
[data-theme="dark"] {
    color-scheme: dark;
}

[data-theme="dark"] body {
    background-color: #0d1117;
    color: #c9d1d9;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4 {
    color: #e6edf3;
}

[data-theme="dark"] h1 {
    border-bottom-color: #30363d;
}

/* Unified callout styling - minimal colors */
[data-theme="dark"] .callout-note,
[data-theme="dark"] .callout-important,
[data-theme="dark"] .callout-tip,
[data-theme="dark"] .callout-warning,
[data-theme="dark"] .callout-theorem,
[data-theme="dark"] .callout-definition,
[data-theme="dark"] .callout-proof,
[data-theme="dark"] .callout-lemma,
[data-theme="dark"] .callout-corollary,
[data-theme="dark"] .callout-example,
[data-theme="dark"] .callout-exercise,
[data-theme="dark"] .callout-explain,
[data-theme="dark"] .callout-caution {
    background-color: #161b22;
    border-color: #30363d;
    border-left-color: #58a6ff;
    color: #c9d1d9;
}

/* All callout headers unified */
[data-theme="dark"] .callout-note .callout-header,
[data-theme="dark"] .callout-note .callout-title,
[data-theme="dark"] .callout-note .callout-title-container,
[data-theme="dark"] .callout-important .callout-header,
[data-theme="dark"] .callout-important .callout-title,
[data-theme="dark"] .callout-important .callout-title-container,
[data-theme="dark"] .callout-tip .callout-header,
[data-theme="dark"] .callout-tip .callout-title,
[data-theme="dark"] .callout-tip .callout-title-container,
[data-theme="dark"] .callout-warning .callout-header,
[data-theme="dark"] .callout-warning .callout-title,
[data-theme="dark"] .callout-warning .callout-title-container,
[data-theme="dark"] .callout-example .callout-header,
[data-theme="dark"] .callout-explain .callout-header,
[data-theme="dark"] .callout-caution .callout-header,
[data-theme="dark"] .callout-exercise .callout-header,
[data-theme="dark"] .callout-proof .callout-header,
[data-theme="dark"] .callout-theorem .callout-header,
[data-theme="dark"] .callout-lemma .callout-header,
[data-theme="dark"] .callout-corollary .callout-header,
[data-theme="dark"] .callout-definition .callout-header,
[data-theme="dark"] .callout-example .callout-title,
[data-theme="dark"] .callout-explain .callout-title,
[data-theme="dark"] .callout-caution .callout-title,
[data-theme="dark"] .callout-exercise .callout-title,
[data-theme="dark"] .callout-proof .callout-title,
[data-theme="dark"] .callout-theorem .callout-title,
[data-theme="dark"] .callout-lemma .callout-title,
[data-theme="dark"] .callout-corollary .callout-title,
[data-theme="dark"] .callout-definition .callout-title {
    color: #e6edf3;
    background-color: transparent !important;
    border-bottom: none;
}

/* All callout bodies */
[data-theme="dark"] .callout-body {
    color: #c9d1d9 !important;
}

/* Code blocks */
[data-theme="dark"] pre,
[data-theme="dark"] code,
[data-theme="dark"] .sourceCode {
    background-color: #161b22;
    color: #c9d1d9;
    border-color: #30363d;
}

/* Links - subtle, monochromatic */
[data-theme="dark"] a {
    color: #8b949e;
}

[data-theme="dark"] a:hover {
    color: #c9d1d9;
    border-bottom-color: #58a6ff;
}

[data-theme="dark"] a:visited {
    color: #8b949e;
}

/* Tables */
[data-theme="dark"] table {
    background-color: #0d1117;
    color: #c9d1d9;
}

[data-theme="dark"] th,
[data-theme="dark"] td {
    border-color: #21262d;
}

[data-theme="dark"] thead {
    border-bottom-color: #30363d;
}

/* Navigation and footer - minimal */
[data-theme="dark"] .navbar,
[data-theme="dark"] footer,
[data-theme="dark"] .footer,
[data-theme="dark"] .nav-footer,
[data-theme="dark"] .nav-footer-left,
[data-theme="dark"] .nav-footer-center,
[data-theme="dark"] .nav-footer-right,
[data-theme="dark"] .page-footer,
[data-theme="dark"] .page-navigation,
[data-theme="dark"] .nav-page,
[data-theme="dark"] .pagination-link {
    background-color: #0d1117 !important;
    color: #c9d1d9 !important;
    border-color: #21262d !important;
}

/* Sidebar */
[data-theme="dark"] .quarto-sidebar,
[data-theme="dark"] .sidebar,
[data-theme="dark"] .nav-sidebar,
[data-theme="dark"] .sidebar-content,
[data-theme="dark"] .sidebar-menu,
[data-theme="dark"] .sidebar-item {
    background-color: #0d1117 !important;
    color: #c9d1d9 !important;
    border-right-color: #21262d !important;
}

[data-theme="dark"] .quarto-sidebar .sidebar-item a,
[data-theme="dark"] .sidebar a,
[data-theme="dark"] .nav-sidebar a,
[data-theme="dark"] .sidebar-menu a {
    color: #8b949e !important;
}

[data-theme="dark"] .quarto-sidebar .sidebar-item a:hover,
[data-theme="dark"] .sidebar a:hover,
[data-theme="dark"] .nav-sidebar a:hover,
[data-theme="dark"] .sidebar-menu a:hover {
    color: #c9d1d9 !important;
    background-color: #161b22 !important;
}

/* TOC */
[data-theme="dark"] #TOC .active {
    color: #c9d1d9 !important;
}

/* Search */
[data-theme="dark"] .navbar-search,
[data-theme="dark"] .search-input,
[data-theme="dark"] input[type="search"],
[data-theme="dark"] .form-control,
[data-theme="dark"] .search-bar {
    background-color: #0d1117 !important;
    color: #c9d1d9 !important;
    border-color: #30363d !important;
}

[data-theme="dark"] .navbar-search::placeholder,
[data-theme="dark"] .search-input::placeholder,
[data-theme="dark"] input[type="search"]::placeholder,
[data-theme="dark"] .form-control::placeholder {
    color: #6e7681 !important;
}

[data-theme="dark"] .search-results,
[data-theme="dark"] .dropdown-menu,
[data-theme="dark"] .search-dropdown {
    background-color: #161b22 !important;
    color: #c9d1d9 !important;
    border-color: #30363d !important;
}

[data-theme="dark"] .search-results a,
[data-theme="dark"] .dropdown-menu a,
[data-theme="dark"] .search-dropdown a {
    color: #8b949e !important;
}

[data-theme="dark"] .search-results a:hover,
[data-theme="dark"] .dropdown-menu a:hover,
[data-theme="dark"] .search-dropdown a:hover {
    background-color: #21262d !important;
    color: #c9d1d9 !important;
}

/* Main content */
[data-theme="dark"] .main,
[data-theme="dark"] .content,
[data-theme="dark"] .quarto-layout-content {
    background-color: #0d1117;
    color: #c9d1d9;
}

/* Buttons and inputs */
[data-theme="dark"] .btn,
[data-theme="dark"] button {
    background-color: #21262d;
    color: #c9d1d9;
    border-color: #30363d;
}

[data-theme="dark"] .btn:hover,
[data-theme="dark"] button:hover {
    background-color: #30363d;
    border-color: #484f58;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background-color: #0d1117;
    color: #c9d1d9;
    border-color: #30363d;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    border-color: #58a6ff;
    box-shadow: 0 0 0 0.2rem rgba(88, 166, 255, 0.3);
}

/* Text emphasis */
[data-theme="dark"] strong,
[data-theme="dark"] b {
    color: #e6edf3;
    font-weight: 600;
}

[data-theme="dark"] em,
[data-theme="dark"] i {
    color: #c9d1d9;
}

/* Blockquotes */
[data-theme="dark"] blockquote {
    border-left-color: #30363d;
    background-color: #161b22;
    color: #8b949e;
}

/* Custom theorem blocks */
[data-theme="dark"] div[id^="def-"],
[data-theme="dark"] div[id^="thm-"],
[data-theme="dark"] div[id^="cor-"],
[data-theme="dark"] div[id^="lem-"],
[data-theme="dark"] div[id^="prop-"],
[data-theme="dark"] div[id^="exm-"] {
    background-color: #161b22;
    color: #c9d1d9;
    border-color: #30363d;
    border-left-color: #58a6ff;
}

[data-theme="dark"] div[id^="def-"] > h3,
[data-theme="dark"] div[id^="def-"] > h2,
[data-theme="dark"] div[id^="thm-"] > h3,
[data-theme="dark"] div[id^="thm-"] > h2,
[data-theme="dark"] div[id^="cor-"] > h3,
[data-theme="dark"] div[id^="cor-"] > h2,
[data-theme="dark"] div[id^="lem-"] > h3,
[data-theme="dark"] div[id^="lem-"] > h2,
[data-theme="dark"] div[id^="prop-"] > h3,
[data-theme="dark"] div[id^="prop-"] > h2,
[data-theme="dark"] div[id^="exm-"] > h3,
[data-theme="dark"] div[id^="exm-"] > h2 {
    color: #e6edf3 !important;
}

/* Math */
[data-theme="dark"] .math,
[data-theme="dark"] .MathJax,
[data-theme="dark"] .katex {
    color: #c9d1d9;
}

/* Figure borders */
[data-theme="dark"] figure img {
    border-color: #30363d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] figcaption {
    color: #8b949e;
}

/* Cards and panels */
[data-theme="dark"] .card,
[data-theme="dark"] .panel {
    background-color: #161b22;
    color: #c9d1d9;
    border-color: #30363d;
}

/* Theme toggle button */
[data-theme="dark"] .theme-toggle {
    background-color: #21262d;
    color: #c9d1d9;
    border-color: #30363d;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .theme-toggle:hover {
    background-color: #30363d;
    border-color: #58a6ff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8);
}

[data-theme="dark"] .theme-toggle:focus {
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.6), 0 0 0 3px rgba(88, 166, 255, 0.4);
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background-color: #ffffff;
    color: #333333;
    border: 2px solid #e0e0e0;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    line-height: 1;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    border-color: #66a9f0;
    background-color: #f8f9fa;
}

.theme-toggle:active {
    transform: translateY(-1px) scale(0.98);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.theme-toggle:focus {
    outline: none;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(0, 123, 255, 0.25);
}