:root {
    --background-primary: #2d2d2d;
    --background-secondary: #0e0e0e;
    --background-tertiary: #252525;
    --text-primary: #e8e8e8;
    --text-secondary: #b4b4b4;
    --text-muted: #8a8a8a;
    --accent-primary: #c47a4a;
    --accent-secondary: #8b6c4e;
    --link-color: #7fa7d9;
    --border-color: #3d3d3d;
    --table-border-color-head: #98978f;
    --table-border-color: #65645f;
    --code-background: #1a1a1a;
    --code-text: #d4d4d4;
    --keyword-color: #c586c0;
    --string-color: #ce9178;
    --function-color: #dcdcaa;
    --comment-color: #6a9955;
    --number-color: #b5cea8;
}

.title_container {
  display: flex;
  flex-direction: column;
  gap: 0.0;
}

.title_row {
  display: flex;
  justify-content: space-between;
}

.title_row h1 {
  margin-bottom: 0px;
}

.title_subrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 0.0;
  padding: 0;
  margin-bottom: 8px;
}

/* ============================================
   Base Styles
   ============================================ */

html {
    background-color: var(--background-secondary);
    min-height: 100vh;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 18px;
    line-height: 1.65;
    color: var(--text-primary);
    background-color: var(--background-primary);
    max-width: 1012px;
    margin: 0 auto;
    padding: 24px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   Typography
   ============================================ */

h1, h2, h3, h4, h5, h6 {
    margin-top: 24px;
    margin-bottom: 16px;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

h1 {
    font-size: 1.8em;
    margin-top: 0;
    padding-bottom: 0.3em;
}

h2 {
    font-size: 1.44em;
    padding-bottom: 0.3em;
}

h3 {
    font-size: 1.22em;
}

h4 {
    font-size: 1.08em;
}

h5 {
    font-size: 0.95em;
}

h6 {
    font-size: 0.86em;
    color: var(--text-secondary);
}

p {
    margin-top: 0;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* ============================================
   Links
   ============================================ */

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

a:hover {
    text-decoration: underline;
}

/* ============================================
   Lists
   ============================================ */

ul ul,
ul ol,
ol ul,
ol ol {
    padding-left: 1.5em; /* each nested level indents further */
}

ul {
    list-style-type: disc;
}

li {
    margin-bottom: 4px;
    color: var(--text-primary);
}

li::marker {
    color: var(--text-secondary);
}

li > p {
    margin-top: 8px;
    margin-bottom: 8px;
}

/* ============================================
   Code Blocks - Pandoc Support
   ============================================ */

code {
    padding: 2px 6px;
    margin: 0 2px;
    font-size: 0.925em;
    background-color: var(--code-background);
    border-radius: 3px;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    color: var(--code-text);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

pre {
    padding: 0px;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.5;
    background-color: var(--code-background);
    border-radius: 6px;
    margin-top: 0;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

pre code,
pre.sourceCode code {
    display: block;
    padding: 0;
    margin: 0;
    overflow: visible;
    line-height: inherit;
    background-color: transparent;
    border: none;
    font-size: inherit;
    color: var(--code-text);
}

/* Pandoc-specific code block styling */
pre.sourceCode {
    padding: 0px;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.5;
    background-color: var(--code-background);
    border-radius: 6px;
    margin-top: 0;
    margin-bottom: 16px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

code.sourceCode {
    background-color: transparent;
    padding: 0;
    margin: 0;
    border: none;
}

pre[class*="sourceCode"] {
    position: relative;
}

/* Code language label (extracted from class name) */
pre[class*="sourceCode"]::before {
    content: attr(data-language);
    position: absolute;
    top: 6px;
    right: 10px;

    font-size: 0.7em;
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-transform: lowercase;

    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    pointer-events: none;
}

/* Extract language from Pandoc classes like "sourceCode matlab" */
pre.sourceCode.matlab::before { content: "matlab"; }
pre.sourceCode.python::before { content: "python"; }
pre.sourceCode.javascript::before { content: "javascript"; }
pre.sourceCode.java::before { content: "java"; }
pre.sourceCode.cpp::before { content: "c++"; }
pre.sourceCode.c::before { content: "c"; }
pre.sourceCode.bash::before { content: "bash"; }
pre.sourceCode.r::before { content: "r"; }
pre.sourceCode.sql::before { content: "sql"; }
pre.sourceCode.json::before { content: "json"; }
pre.sourceCode.yaml::before { content: "yaml"; }
pre.sourceCode.xml::before { content: "xml"; }
pre.sourceCode.html::before { content: "html"; }
pre.sourceCode.css::before { content: "css"; }

/* Hide label if no language class or data-language attribute */
pre:not([class*="sourceCode"]):not([data-language])::before,
pre[data-language=""]::before {
    content: none;
}

/* Syntax highlighting */
.hljs-keyword { color: #c586c0; }
.hljs-built_in { color: #4ec9b0; }
.hljs-type { color: #4ec9b0; }
.hljs-literal { color: #569cd6; }
.hljs-number { color: #b5cea8; }
.hljs-operator { color: #d4d4d4; }
.hljs-punctuation { color: #d4d4d4; }
.hljs-property { color: #9cdcfe; }
.hljs-regexp { color: #d16969; }
.hljs-string { color: #ce9178; }
.hljs-char.escape_ { color: #d7ba7d; }
.hljs-subst { color: #d4d4d4; }
.hljs-symbol { color: #dcdcaa; }
.hljs-variable { color: #9cdcfe; }
.hljs-variable.language_ { color: #569cd6; }
.hljs-variable.constant_ { color: #4fc1ff; }
.hljs-title { color: #dcdcaa; }
.hljs-title.class_ { color: #4ec9b0; }
.hljs-title.class_.inherited__ { color: #4ec9b0; }
.hljs-title.function_ { color: #dcdcaa; }
.hljs-params { color: #9cdcfe; }
.hljs-comment { color: #6a9955; font-style: italic; }
.hljs-doctag { color: #6a9955; }
.hljs-meta { color: #569cd6; }
.hljs-meta .hljs-keyword { color: #569cd6; }
.hljs-meta .hljs-string { color: #ce9178; }
.hljs-section { color: #ffd700; }
.hljs-tag { color: #808080; }
.hljs-name { color: #569cd6; }
.hljs-attr { color: #9cdcfe; }
.hljs-attribute { color: #9cdcfe; }
.hljs-addition { color: #b5cea8; background-color: rgba(144, 238, 144, 0.2); }
.hljs-deletion { color: #ce9178; background-color: rgba(255, 0, 0, 0.2); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: bold; }

/* ============================================
   Blockquotes
   ============================================ */

blockquote {
    padding: 0 16px;
    margin: 0 0 16px 0;
    color: var(--text-secondary);
    border-left: 4px solid var(--border-color);
}

blockquote > :first-child {
    margin-top: 0;
}

blockquote > :last-child {
    margin-bottom: 0;
}

/* ============================================
   Tables
   ============================================ */

table {
    border-spacing: 0;
    border-collapse: collapse;
    width: 100%;
    overflow: auto;
    margin-bottom: 16px;
    font-size: 0.95em;
}

table thead {
    background-color: transparent;
}

table th {
    font-weight: 600;
    padding: 10px 16px;
    text-align: left;
    border-bottom: 1px solid var(--table-border-color-head);
    color: var(--text-primary);
    background-color: transparent;
}

table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--table-border-color);
    color: var(--text-primary);
}

table tr:last-child td {
    border-bottom: 1px solid var(--table-border-color);
}

table tbody tr {
    background-color: transparent;
}

table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

/* ============================================
   Horizontal Rules
   ============================================ */

hr {
    height: 1px;
    padding: 0;
    margin: 24px 0;
    background-color: var(--border-color);
    border: 0;
}

/* ============================================
   Images
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

img.rounded {
    border-radius: 15px;
}

/* ============================================
   Emphasis
   ============================================ */

em, i {
    font-style: italic;
    color: var(--text-primary);
}

strong, b {
    font-weight: 600;
    color: var(--text-primary);
}

del, s {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* ============================================
   Numbered Lists (Ordered Lists)
   ============================================ */

ol {
    counter-reset: list-counter;
    list-style: none;
    padding-left: 0;
}

/* Change: Use '>' to target only direct children */
ol > li {
    counter-increment: list-counter;
    position: relative;
    padding-left: 2em;
}

/* Change: Use '>' here too */
ol > li::before {
    content: counter(list-counter) ".";
    position: absolute;
    left: 0;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Nested ordered lists - Update to use direct children */
ol ol > li::before {
    content: counter(list-counter, lower-alpha) ".";
}

ol ol ol > li::before {
    content: counter(list-counter, lower-roman) ".";
}

/* ============================================
   Definition Lists
   ============================================ */

dl {
    padding: 0;
}

dl dt {
    padding: 0;
    margin-top: 16px;
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
}

dl dd {
    padding: 0 16px;
    margin-bottom: 16px;
    color: var(--text-secondary);
}

/* ============================================
   Details/Summary
   ============================================ */

details {
    margin-bottom: 16px;
}

summary {
    cursor: pointer;
    font-weight: 600;
    padding: 8px 12px;
    background-color: var(--background-tertiary);
    border-radius: 4px;
    outline: none;
    color: var(--text-primary);
}

summary:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

details[open] summary {
    margin-bottom: 12px;
}

/* ============================================
   Keyboard Keys
   ============================================ */

kbd {
    display: inline-block;
    padding: 3px 6px;
    font-size: 0.85em;
    line-height: 1;
    color: var(--text-primary);
    vertical-align: middle;
    background-color: var(--background-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
    font-family: "Consolas", "Monaco", "Courier New", monospace;
}

/* ============================================
   Selection
   ============================================ */

::selection {
    background-color: rgba(124, 158, 217, 0.3);
    color: var(--text-primary);
}

::-moz-selection {
    background-color: rgba(124, 158, 217, 0.3);
    color: var(--text-primary);
}

/* ============================================
   Scrollbar Styling (Webkit browsers)
   ============================================ */

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   Utility Classes
   ============================================ */

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

/* ============================================
   Print Styles
   ============================================ */

@media print {
    body {
        background-color: white;
        color: black;
    }
    
    pre, code {
        background-color: #f5f5f5;
        color: black;
        border: 1px solid #ccc;
    }
    
    a {
        color: #0366d6;
        text-decoration: underline;
    }
}

/* ============================================
   Mobile Responsive
   ============================================ */

@media (max-width: 768px) {
    body {
        padding: 16px;
        font-size: 14px;
    }
    
    h1 {
        font-size: 1.5em;
    }
    
    h2 {
        font-size: 1.25em;
    }
    
    pre {
        padding: 12px;
        font-size: 0.8em;
    }
    
    table {
        font-size: 0.85em;
    }
    
    table th,
    table td {
        padding: 8px 10px;
    }
}
