/* Code block language title strips - target outer scaffold */
.code-copy-outer-scaffold {
    position: relative;
    margin-top: 2rem !important;
}


/* Base title strip style - positioned above the outer scaffold */
.code-copy-outer-scaffold::before {
    content: "Code";
    position: absolute;
    top: -1.5rem;
    left: 0;
    right: 0;
    height: 1.5rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.2rem 0.75rem;
    border-radius: 0.375rem 0.375rem 0 0;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    color: white;
}

/* Julia - Purple (brand color) */
.code-copy-outer-scaffold:has(pre.julia)::before {
    content: "Julia";
    background: linear-gradient(135deg, #9558b2 0%, #7a4a94 100%);
}

/* Python - Blue (brand color) */
.code-copy-outer-scaffold:has(pre.python)::before {
    content: "Python";
    background: linear-gradient(135deg, #3776ab 0%, #2d5a87 100%);
}

/* R - Blue (brand color) */
.code-copy-outer-scaffold:has(pre.r)::before {
    content: "R";
    background: linear-gradient(135deg, #276dc3 0%, #1e5a9e 100%);
}

/* Terminal/Shell - Gray */
.code-copy-outer-scaffold:has(pre.bash)::before,
.code-copy-outer-scaffold:has(pre.zsh)::before {
    content: "Terminal";
    background: linear-gradient(135deg, #4a5568 0%, #2d3748 100%);
}

/* JavaScript - Yellow */
.code-copy-outer-scaffold:has(pre.javascript)::before,
.code-copy-outer-scaffold:has(pre.js)::before {
    content: "JavaScript";
    background: linear-gradient(135deg, #f7df1e 0%, #e6c200 100%);
    color: #323330;
}

/* TypeScript - Blue */
.code-copy-outer-scaffold:has(pre.typescript)::before,
.code-copy-outer-scaffold:has(pre.ts)::before {
    content: "TypeScript";
    background: linear-gradient(135deg, #3178c6 0%, #265a94 100%);
}

/* HTML - Orange */
.code-copy-outer-scaffold:has(pre.html)::before {
    content: "HTML";
    background: linear-gradient(135deg, #e34c26 0%, #b83c1e 100%);
}

/* CSS - Blue */
.code-copy-outer-scaffold:has(pre.css)::before {
    content: "CSS";
    background: linear-gradient(135deg, #264de4 0%, #1e3eb8 100%);
}

/* Markdown - Gray */
.code-copy-outer-scaffold:has(pre.markdown)::before,
.code-copy-outer-scaffold:has(pre.md)::before {
    content: "Markdown";
    background: linear-gradient(135deg, #6a737d 0%, #4a525a 100%);
}

/* TOML - Red/Orange */
.code-copy-outer-scaffold:has(pre.toml)::before {
    content: "TOML";
    background: linear-gradient(135deg, #9c4121 0%, #7a331a 100%);
}

/* YAML - Red */
.code-copy-outer-scaffold:has(pre.yaml)::before,
.code-copy-outer-scaffold:has(pre.yml)::before {
    content: "YAML";
    background: linear-gradient(135deg, #cb171e 0%, #a01217 100%);
}

/* JSON - Green */
.code-copy-outer-scaffold:has(pre.json)::before {
    content: "JSON";
    background: linear-gradient(135deg, #6d9c00 0%, #5a7f00 100%);
}

/* Header section numbers */
.header-section-number::after {
    content: ".";
}

.header-section-number {
    color: oklch(45% 0.14 250);
}

[data-theme="dark"] .header-section-number {
    color: oklch(75% 0.1 250);
}

/* Light-mode ANSI colors for terminal output */
[data-bs-theme="light"] .ansi-black-fg {
    color: #1f2937;
}

[data-bs-theme="light"] .ansi-red-fg {
    color: #dc2626;
}

[data-bs-theme="light"] .ansi-green-fg {
    color: #16a34a;
}

[data-bs-theme="light"] .ansi-yellow-fg {
    color: #ca8a04;
}

[data-bs-theme="light"] .ansi-blue-fg {
    color: #2563eb;
}

[data-bs-theme="light"] .ansi-magenta-fg {
    color: #9333ea;
}

[data-bs-theme="light"] .ansi-cyan-fg {
    color: #0891b2;
}

[data-bs-theme="light"] .ansi-white-fg {
    color: #f3f4f6;
}

[data-bs-theme="light"] .ansi-bright-black-fg {
    color: #6b7280;
}

[data-bs-theme="light"] .ansi-bright-red-fg {
    color: #ef4444;
}

[data-bs-theme="light"] .ansi-bright-green-fg {
    color: #22c55e;
}

[data-bs-theme="light"] .ansi-bright-yellow-fg {
    color: #eab308;
}

[data-bs-theme="light"] .ansi-bright-blue-fg {
    color: #3b82f6;
}

[data-bs-theme="light"] .ansi-bright-magenta-fg {
    color: #a855f7;
}

[data-bs-theme="light"] .ansi-bright-cyan-fg {
    color: #06b6d4;
}

[data-bs-theme="light"] .ansi-bright-white-fg {
    color: #ffffff;
}

/* Light-mode styling for code blocks - whiter background */
[data-bs-theme="light"] div.sourceCode.cell-code,
[data-bs-theme="light"] div.sourceCode {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
}

[data-bs-theme="light"] div.sourceCode pre.sourceCode,
[data-bs-theme="light"] pre.sourceCode {
    background-color: transparent;
    color: #334155;
}

[data-bs-theme="light"] .cell-output pre,
[data-bs-theme="light"] .cell-output-stdout pre,
[data-bs-theme="light"] .cell-output-stderr pre,
[data-bs-theme="light"] .cell-output-display pre {
    background-color: #f8fafc;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
}

/* Light mode: make bright-black text visible on white background */
[data-bs-theme="light"] .cell-output pre .ansi-bright-black-fg,
[data-bs-theme="light"] .cell-output-stdout pre .ansi-bright-black-fg,
[data-bs-theme="light"] .cell-output-display pre .ansi-bright-black-fg {
    color: #9ca3af;
}

/* Dark-mode styling for Jupyter notebook (.ipynb) cell outputs and code blocks */
[data-bs-theme="dark"] .cell-output pre,
[data-bs-theme="dark"] .cell-output-stdout pre,
[data-bs-theme="dark"] .cell-output-stderr pre,
[data-bs-theme="dark"] .cell-output-display pre {
    background-color: oklch(22% 0.01 260);
    color: oklch(92% 0.01 260);
    border: 1px solid oklch(30% 0.01 260);
    border-radius: 0.375rem;
    padding: 0.75rem 1rem;
}

[data-bs-theme="dark"] .cell-output-stderr pre {
    background-color: oklch(25% 0.04 25);
    color: oklch(90% 0.05 25);
    border-color: oklch(35% 0.06 25);
}

[data-bs-theme="dark"] div.sourceCode.cell-code,
[data-bs-theme="dark"] div.sourceCode {
    background-color: oklch(22% 0.01 260);
    border: 1px solid oklch(30% 0.01 260);
    border-radius: 0.375rem;
}

[data-bs-theme="dark"] div.sourceCode pre.sourceCode,
[data-bs-theme="dark"] pre.sourceCode {
    background-color: transparent;
    color: oklch(92% 0.01 260);
}

/* Dark mode: inline code (syntax highlighting span.in) */
[data-bs-theme="dark"] code span.in {
    color: #a5d6ff;
}

/* Dark mode syntax highlighting colors */
[data-bs-theme="dark"] {
    /* Base code colors - light for dark backgrounds */
    --quarto-hl-ot-color: #7ee787;
    --quarto-hl-at-color: #79c0ff;
    --quarto-hl-ss-color: #a5d6ff;
    --quarto-hl-an-color: #8b949e;
    --quarto-hl-fu-color: #d2a8ff;
    --quarto-hl-st-color: #a5d6ff;
    --quarto-hl-cf-color: #ff7b72;
    --quarto-hl-op-color: #8b949e;
    --quarto-hl-er-color: #f85149;
    --quarto-hl-bn-color: #79c0ff;
    --quarto-hl-al-color: #f85149;
    --quarto-hl-va-color: #ffa657;
    --quarto-hl-bu-color: inherit;
    --quarto-hl-ex-color: inherit;
    --quarto-hl-pp-color: #ff7b72;
    --quarto-hl-in-color: #8b949e;
    --quarto-hl-vs-color: #a5d6ff;
    --quarto-hl-wa-color: #e3b341;
    --quarto-hl-do-color: #8b949e;
    --quarto-hl-im-color: #7ee787;
    --quarto-hl-ch-color: #a5d6ff;
    --quarto-hl-dt-color: #ff7b72;
    --quarto-hl-fl-color: #79c0ff;
    --quarto-hl-co-color: #8b949e;
    --quarto-hl-cv-color: #8b949e;
    --quarto-hl-cn-color: #79c0ff;
    --quarto-hl-sc-color: #8b949e;
    --quarto-hl-dv-color: #79c0ff;
    --quarto-hl-kw-color: #ff7b72;
}

[data-bs-theme="dark"] pre>code.sourceCode>span,
[data-bs-theme="dark"] code.sourceCode>span {
    color: #e6edf3;
}

[data-bs-theme="dark"] div.sourceCode,
[data-bs-theme="dark"] div.sourceCode pre.sourceCode {
    color: #e6edf3;
}

[data-bs-theme="dark"] code span {
    color: #e6edf3;
}

/* Alert */
[data-bs-theme="dark"] code span.al {
    color: #f85149;
    font-style: inherit;
}

/* Annotation */
[data-bs-theme="dark"] code span.an {
    color: #8b949e;
    font-style: inherit;
}

/* Attribute */
[data-bs-theme="dark"] code span.at {
    color: #79c0ff;
    font-style: inherit;
}

/* BaseN */
[data-bs-theme="dark"] code span.bn {
    color: #79c0ff;
    font-style: inherit;
}

/* BuiltIn */
[data-bs-theme="dark"] code span.bu {
    font-style: inherit;
}

/* ControlFlow */
[data-bs-theme="dark"] code span.cf {
    color: #ff7b72;
    font-weight: bold;
    font-style: inherit;
}

/* Char */
[data-bs-theme="dark"] code span.ch {
    color: #a5d6ff;
    font-style: inherit;
}

/* Constant */
[data-bs-theme="dark"] code span.cn {
    color: #79c0ff;
    font-style: inherit;
}

/* Comment */
[data-bs-theme="dark"] code span.co {
    color: #8b949e;
    font-style: inherit;
}

/* CommentVar */
[data-bs-theme="dark"] code span.cv {
    color: #8b949e;
    font-style: italic;
}

/* Documentation */
[data-bs-theme="dark"] code span.do {
    color: #8b949e;
    font-style: italic;
}

/* DataType */
[data-bs-theme="dark"] code span.dt {
    color: #ff7b72;
    font-style: inherit;
}

/* DecVal */
[data-bs-theme="dark"] code span.dv {
    color: #79c0ff;
    font-style: inherit;
}

/* Error */
[data-bs-theme="dark"] code span.er {
    color: #f85149;
    font-style: inherit;
}

/* Extension */
[data-bs-theme="dark"] code span.ex {
    font-style: inherit;
}

/* Float */
[data-bs-theme="dark"] code span.fl {
    color: #79c0ff;
    font-style: inherit;
}

/* Function */
[data-bs-theme="dark"] code span.fu {
    color: #d2a8ff;
    font-style: inherit;
}

/* Import */
[data-bs-theme="dark"] code span.im {
    color: #7ee787;
    font-style: inherit;
}

/* Information */
[data-bs-theme="dark"] code span.in {
    color: #8b949e;
    font-style: inherit;
}

/* Keyword */
[data-bs-theme="dark"] code span.kw {
    color: #ff7b72;
    font-weight: bold;
    font-style: inherit;
}

/* Operator */
[data-bs-theme="dark"] code span.op {
    color: #8b949e;
    font-style: inherit;
}

/* Other */
[data-bs-theme="dark"] code span.ot {
    color: #7ee787;
    font-style: inherit;
}

/* Preprocessor */
[data-bs-theme="dark"] code span.pp {
    color: #ff7b72;
    font-style: inherit;
}

/* SpecialChar */
[data-bs-theme="dark"] code span.sc {
    color: #8b949e;
    font-style: inherit;
}

/* SpecialString */
[data-bs-theme="dark"] code span.ss {
    color: #a5d6ff;
    font-style: inherit;
}

/* String */
[data-bs-theme="dark"] code span.st {
    color: #a5d6ff;
    font-style: inherit;
}

/* Variable */
[data-bs-theme="dark"] code span.va {
    color: #ffa657;
    font-style: inherit;
}

/* VerbatimString */
[data-bs-theme="dark"] code span.vs {
    color: #a5d6ff;
    font-style: inherit;
}

/* Warning */
[data-bs-theme="dark"] code span.wa {
    color: #e3b341;
    font-style: italic;
}

/* Fix for error messages and stderr output */
[data-bs-theme="dark"] .cell-output-stderr {
    color: #ff7b72 !important;
}

[data-bs-theme="dark"] .cell-output-stderr pre,
[data-bs-theme="dark"] .cell-output-stderr code {
    color: #ff7b72 !important;
    background-color: oklch(25% 0.04 25) !important;
}

/* ANSI colors for terminal output in dark mode */
/* Standard foreground colors */
[data-bs-theme="dark"] .ansi-black-fg {
    color: #484f58;
}

[data-bs-theme="dark"] .ansi-red-fg {
    color: #ff7b72;
}

[data-bs-theme="dark"] .ansi-green-fg {
    color: #7ee787;
}

[data-bs-theme="dark"] .ansi-yellow-fg {
    color: #e3b341;
}

[data-bs-theme="dark"] .ansi-blue-fg {
    color: #79c0ff;
}

[data-bs-theme="dark"] .ansi-magenta-fg {
    color: #d2a8ff;
}

[data-bs-theme="dark"] .ansi-cyan-fg {
    color: #56d4dd;
}

[data-bs-theme="dark"] .ansi-white-fg {
    color: #e6edf3;
}

/* Bright foreground colors */
[data-bs-theme="dark"] .ansi-bright-black-fg {
    color: #6e7681;
}

[data-bs-theme="dark"] .ansi-bright-red-fg {
    color: #ffa198;
}

[data-bs-theme="dark"] .ansi-bright-green-fg {
    color: #56d364;
}

[data-bs-theme="dark"] .ansi-bright-yellow-fg {
    color: #e3b341;
}

[data-bs-theme="dark"] .ansi-bright-blue-fg {
    color: #79c0ff;
}

[data-bs-theme="dark"] .ansi-bright-magenta-fg {
    color: #d2a8ff;
}

[data-bs-theme="dark"] .ansi-bright-cyan-fg {
    color: #39c5cf;
}

[data-bs-theme="dark"] .ansi-bright-white-fg {
    color: #ffffff;
}

/* Background colors (if used) */
[data-bs-theme="dark"] .ansi-black-bg {
    background-color: #484f58;
}

[data-bs-theme="dark"] .ansi-red-bg {
    background-color: #ff7b72;
}

[data-bs-theme="dark"] .ansi-green-bg {
    background-color: #7ee787;
}

[data-bs-theme="dark"] .ansi-yellow-bg {
    background-color: #e3b341;
}

[data-bs-theme="dark"] .ansi-blue-bg {
    background-color: #79c0ff;
}

[data-bs-theme="dark"] .ansi-magenta-bg {
    background-color: #d2a8ff;
}

[data-bs-theme="dark"] .ansi-cyan-bg {
    background-color: #56d4dd;
}

[data-bs-theme="dark"] .ansi-white-bg {
    background-color: #e6edf3;
}

/* Bold text */
[data-bs-theme="dark"] .ansi-bold {
    font-weight: bold;
}

/* Box drawing characters and special symbols */
[data-bs-theme="dark"] pre,
[data-bs-theme="dark"] code {
    color: #ffffff;
}

/* Default text color for output but allow ANSI colors (no !important) */
[data-bs-theme="dark"] .cell-output,
[data-bs-theme="dark"] .cell-output-stdout,
[data-bs-theme="dark"] .cell-output-display {
    color: #e6edf3;
}

/* Add bottom margin to cell-output-display */
.cell-output.cell-output-display {
    margin-bottom: 1.5rem;
}

[data-bs-theme="dark"] .cell-output pre,
[data-bs-theme="dark"] .cell-output-stdout pre,
[data-bs-theme="dark"] .cell-output-display pre {
    color: #e6edf3;
}

/* ANSI colors - must be more specific than default */
[data-bs-theme="dark"] .cell-output pre [class*="ansi-"],
[data-bs-theme="dark"] .cell-output-stdout pre [class*="ansi-"],
[data-bs-theme="dark"] .cell-output-display pre [class*="ansi-"] {
    color: inherit;
}

[data-bs-theme="dark"] .cell-output pre .ansi-black,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-black,
[data-bs-theme="dark"] .cell-output-display pre .ansi-black {
    color: #000000;
}

[data-bs-theme="dark"] .cell-output pre .ansi-red,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-red,
[data-bs-theme="dark"] .cell-output-display pre .ansi-red {
    color: #ff7b72;
}

[data-bs-theme="dark"] .cell-output pre .ansi-green,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-green,
[data-bs-theme="dark"] .cell-output-display pre .ansi-green {
    color: #7ee787;
}

[data-bs-theme="dark"] .cell-output pre .ansi-yellow,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-yellow,
[data-bs-theme="dark"] .cell-output-display pre .ansi-yellow {
    color: #e3b341;
}

[data-bs-theme="dark"] .cell-output pre .ansi-blue,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-blue,
[data-bs-theme="dark"] .cell-output-display pre .ansi-blue {
    color: #79c0ff;
}

[data-bs-theme="dark"] .cell-output pre .ansi-magenta,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-magenta,
[data-bs-theme="dark"] .cell-output-display pre .ansi-magenta {
    color: #d2a8ff;
}

[data-bs-theme="dark"] .cell-output pre .ansi-cyan,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-cyan,
[data-bs-theme="dark"] .cell-output-display pre .ansi-cyan {
    color: #56d4dd;
}

[data-bs-theme="dark"] .cell-output pre .ansi-white,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-white,
[data-bs-theme="dark"] .cell-output-display pre .ansi-white {
    color: #e6edf3;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-black,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-black,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-black {
    color: #484f58;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-red,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-red,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-red {
    color: #ffa198;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-green,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-green,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-green {
    color: #56d364;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-yellow,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-yellow,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-yellow {
    color: #e3b341;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-blue,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-blue,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-blue {
    color: #79c0ff;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-magenta,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-magenta,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-magenta {
    color: #d2a8ff;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-cyan,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-cyan,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-cyan {
    color: #39c5cf;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-white,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-white,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-white {
    color: #ffffff;
}

/* Specific selectors for -fg classes (used by Jupyter/ANSI output) */
[data-bs-theme="dark"] .cell-output pre .ansi-green-fg,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-green-fg,
[data-bs-theme="dark"] .cell-output-display pre .ansi-green-fg {
    color: #7ee787;
}

[data-bs-theme="dark"] .cell-output pre .ansi-yellow-fg,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-yellow-fg,
[data-bs-theme="dark"] .cell-output-display pre .ansi-yellow-fg {
    color: #e3b341;
}

[data-bs-theme="dark"] .cell-output pre .ansi-bright-black-fg,
[data-bs-theme="dark"] .cell-output-stdout pre .ansi-bright-black-fg,
[data-bs-theme="dark"] .cell-output-display pre .ansi-bright-black-fg {
    color: #ffffcc;
}

/* Theme toggle button styles */
.theme-toggle {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: #1a1a1a;
    color: white;
    cursor: pointer;
    transition: all 250ms ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

[data-theme="light"] .theme-toggle {
    background: white;
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.theme-toggle:hover {
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle__icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: opacity 250ms ease;
    display: flex;
    align-items: center;
    justify-content: center;
}