/* Override Jupyter CSS variables to match the github-style theme.
   Scoped to .jupyter-notebook-container so these inherited values
   take precedence over Jupyter's :root definitions for all descendants. */

.jupyter-notebook-container {
  /* Backgrounds */
  --jp-layout-color0: #ffffff;
  --jp-layout-color1: #f6f8fa;
  --jp-layout-color2: #eaeef2;
  --jp-layout-color3: #d0d7de;
  --jp-layout-color4: #afb8c1;

  /* Inverse (dark surfaces) */
  --jp-inverse-layout-color0: #24292f;
  --jp-inverse-layout-color1: #32383f;
  --jp-inverse-layout-color2: #57606a;
  --jp-inverse-layout-color3: #6e7781;
  --jp-inverse-layout-color4: #8c959f;

  /* Text */
  --jp-content-font-color0: #24292f;
  --jp-content-font-color1: #24292f;
  --jp-content-font-color2: #57606a;
  --jp-content-font-color3: #6e7781;
  --jp-content-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans", Helvetica, Arial, sans-serif;
  --jp-content-font-size1: 14px;
  --jp-content-line-height: 1.5;

  /* Code */
  --jp-code-font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --jp-code-font-family-default: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --jp-code-font-size: 85%;
  --jp-code-line-height: 1.45;
  --jp-code-padding: 0.2em 0.4em;

  /* Borders */
  --jp-border-color0: #d0d7de;
  --jp-border-color1: #d0d7de;
  --jp-border-color2: #eaeef2;
  --jp-border-color3: #f6f8fa;

  /* Brand / accent (GitHub blue) */
  --jp-brand-color0: #0550ae;
  --jp-brand-color1: #0969da;
  --jp-brand-color2: #54aeff;
  --jp-brand-color3: #ddf4ff;
  --jp-brand-color4: #f0f8ff;

  /* Cell editor (code input area) */
  --jp-cell-editor-background: #f6f8fa;
  --jp-cell-editor-background-color: #f6f8fa;
  --jp-cell-editor-active-background: #ffffff;
  --jp-cell-editor-border-color: #d0d7de;
  --jp-cell-editor-active-border-color: #0969da;
  --jp-cell-editor-box-shadow: inset 0 0 0 1px #0969da;

  /* Prompts */
  --jp-cell-inprompt-font-color: #0969da;
  --jp-cell-outprompt-font-color: #cf222e;
  --jp-cell-prompt-not-active-font-color: #6e7781;

  /* Semantic */
  --jp-error-color0: #cf222e;
  --jp-error-color1: #cf222e;
  --jp-error-color2: #f85149;
  --jp-error-color3: #ffebe9;
  --jp-warn-color0: #9a6700;
  --jp-warn-color1: #9a6700;
  --jp-warn-color2: #d4a72c;
  --jp-warn-color3: #fff8c5;
  --jp-success-color0: #1a7f37;
  --jp-success-color1: #2da44e;
  --jp-success-color2: #4ac26b;
  --jp-success-color3: #dafbe1;

  --jp-shadow-base-lightness: 0;
}

/* Dark mode */
[data-color-mode=dark] .jupyter-notebook-container {
  --jp-layout-color0: #0d1117;
  --jp-layout-color1: #161b22;
  --jp-layout-color2: #21262d;
  --jp-layout-color3: #30363d;
  --jp-layout-color4: #484f58;

  --jp-inverse-layout-color0: #f0f6fc;
  --jp-inverse-layout-color1: #e6edf3;
  --jp-inverse-layout-color2: #c9d1d9;
  --jp-inverse-layout-color3: #8b949e;
  --jp-inverse-layout-color4: #6e7681;

  --jp-content-font-color0: #e6edf3;
  --jp-content-font-color1: #c9d1d9;
  --jp-content-font-color2: #8b949e;
  --jp-content-font-color3: #6e7681;

  --jp-border-color0: #30363d;
  --jp-border-color1: #30363d;
  --jp-border-color2: #21262d;
  --jp-border-color3: #161b22;

  --jp-brand-color0: #1f6feb;
  --jp-brand-color1: #388bfd;
  --jp-brand-color2: #79c0ff;
  --jp-brand-color3: #0d1117;
  --jp-brand-color4: #0a0d12;

  --jp-cell-editor-background: #161b22;
  --jp-cell-editor-background-color: #161b22;
  --jp-cell-editor-active-background: #0d1117;
  --jp-cell-editor-border-color: #30363d;
  --jp-cell-editor-active-border-color: #388bfd;
  --jp-cell-editor-box-shadow: inset 0 0 0 1px #388bfd;

  --jp-cell-inprompt-font-color: #388bfd;
  --jp-cell-outprompt-font-color: #ff7b72;
  --jp-cell-prompt-not-active-font-color: #8b949e;

  --jp-error-color0: #ff7b72;
  --jp-error-color1: #ffa198;
  --jp-error-color2: #ff7b72;
  --jp-error-color3: #490202;
  --jp-warn-color0: #d4a72c;
  --jp-warn-color1: #e3b341;
  --jp-warn-color2: #d4a72c;
  --jp-warn-color3: #341a00;
  --jp-success-color0: #3fb950;
  --jp-success-color1: #4ac26b;
  --jp-success-color2: #3fb950;
  --jp-success-color3: #04260f;

  --jp-shadow-base-lightness: 255;

  /* Table row colors — override Jupyter's :root light defaults */
  --jp-rendermime-table-row-background: #161b22;
  --jp-rendermime-table-row-hover-background: rgba(56, 139, 253, 0.1);
  --jp-rendermime-error-background: #490202;
  --jp-ui-font-color1: #c9d1d9;

  /* Syntax highlighting (mirror editor) — override Jupyter's :root light defaults */
  --jp-mirror-editor-keyword-color: #ff7b72;
  --jp-mirror-editor-atom-color: #79c0ff;
  --jp-mirror-editor-number-color: #79c0ff;
  --jp-mirror-editor-def-color: #d2a8ff;
  --jp-mirror-editor-variable-color: #c9d1d9;
  --jp-mirror-editor-variable-2-color: #c9d1d9;
  --jp-mirror-editor-variable-3-color: #ffa657;
  --jp-mirror-editor-punctuation-color: #c9d1d9;
  --jp-mirror-editor-property-color: #79c0ff;
  --jp-mirror-editor-operator-color: #ff7b72;
  --jp-mirror-editor-comment-color: #8b949e;
  --jp-mirror-editor-string-color: #a5d6ff;
  --jp-mirror-editor-string-2-color: #a5d6ff;
  --jp-mirror-editor-meta-color: #ffa657;
  --jp-mirror-editor-qualifier-color: #8b949e;
  --jp-mirror-editor-builtin-color: #79c0ff;
  --jp-mirror-editor-bracket-color: #c9d1d9;
  --jp-mirror-editor-tag-color: #7ee787;
  --jp-mirror-editor-attribute-color: #79c0ff;
  --jp-mirror-editor-header-color: #58a6ff;
  --jp-mirror-editor-quote-color: #a5d6ff;
  --jp-mirror-editor-link-color: #58a6ff;
  --jp-mirror-editor-error-color: #f85149;
  --jp-mirror-editor-hr-color: #30363d;
}

/* Dark mode: ANSI terminal output colors — higher specificity beats Jupyter's inline <style> */
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-black-fg   { color: #6e7681; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-red-fg     { color: #ff7b72; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-green-fg   { color: #3fb950; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-yellow-fg  { color: #e3b341; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-blue-fg    { color: #58a6ff; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-magenta-fg { color: #bc8cff; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-cyan-fg    { color: #76e3ea; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-white-fg   { color: #e6edf3; }

[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-black-intense-fg   { color: #8b949e; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-red-intense-fg     { color: #ffa198; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-green-intense-fg   { color: #56d364; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-yellow-intense-fg  { color: #d29922; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-blue-intense-fg    { color: #79c0ff; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-magenta-intense-fg { color: #d2a8ff; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-cyan-intense-fg    { color: #b3f0ff; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-white-intense-fg   { color: #f0f6fc; }

[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-black-bg   { background-color: #6e7681; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-red-bg     { background-color: #da3633; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-green-bg   { background-color: #238636; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-yellow-bg  { background-color: #9e6a03; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-blue-bg    { background-color: #1f6feb; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-magenta-bg { background-color: #8957e5; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-cyan-bg    { background-color: #1b7c83; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-white-bg   { background-color: #8b949e; }

[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-black-intense-bg   { background-color: #484f58; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-red-intense-bg     { background-color: #b62324; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-green-intense-bg   { background-color: #196c2e; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-yellow-intense-bg  { background-color: #845306; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-blue-intense-bg    { background-color: #1158c7; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-magenta-intense-bg { background-color: #6e40c9; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-cyan-intense-bg    { background-color: #138a8a; }
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedText pre .ansi-white-intense-bg   { background-color: #6e7681; }

/* Fix hardcoded black close-icon and light scrollbar colors */
[data-color-mode=dark] .jupyter-notebook-container .lm-close-icon:after {
  color: var(--jp-content-font-color1);
}

[data-color-mode=dark] .jupyter-notebook-container .lm-ScrollBar-button            { background-color: #30363d; }
[data-color-mode=dark] .jupyter-notebook-container .lm-ScrollBar-button:hover      { background-color: #484f58; }
[data-color-mode=dark] .jupyter-notebook-container .lm-ScrollBar-button.lm-mod-active { background-color: #6e7681; }
[data-color-mode=dark] .jupyter-notebook-container .lm-ScrollBar-track             { background: #21262d; }
[data-color-mode=dark] .jupyter-notebook-container .lm-ScrollBar-thumb             { background: #484f58; }
[data-color-mode=dark] .jupyter-notebook-container .lm-ScrollBar-thumb:hover       { background: #6e7681; }

/* Fix line-number special highlight */
[data-color-mode=dark] .jupyter-notebook-container td.linenos .special,
[data-color-mode=dark] .jupyter-notebook-container span.linenos.special {
  color: #e6edf3;
  background-color: #845306;
}

/* Structural overrides for elements that use hardcoded colors */
.jupyter-notebook-container .jp-Notebook {
  background: var(--jp-layout-color0);
  color: var(--jp-content-font-color1);
}

.jupyter-notebook-container .jp-Cell {
  border: 1px solid transparent;
}

.jupyter-notebook-container .jp-Cell.jp-mod-selected,
.jupyter-notebook-container .jp-Cell.jp-mod-active {
  border-color: var(--jp-cell-editor-active-border-color);
}

.jupyter-notebook-container .jp-MarkdownOutput {
  font-family: var(--jp-content-font-family);
  color: var(--jp-content-font-color1);
}

/* Match the site's code block style */
.jupyter-notebook-container pre {
  background-color: var(--jp-cell-editor-background);
  border: 1px solid var(--jp-border-color1);
  border-radius: 6px;
  color: var(--jp-content-font-color1);
}

.jupyter-notebook-container code {
  font-family: var(--jp-code-font-family);
  font-size: var(--jp-code-font-size);
}

/* Output area */
.jupyter-notebook-container .jp-OutputArea-output {
  background: var(--jp-layout-color0);
  color: var(--jp-content-font-color1);
}

.jupyter-notebook-container .jp-OutputArea-output pre {
  color: var(--jp-content-font-color1);
  background: var(--jp-layout-color1);
}

/* Stdout/stderr */
.jupyter-notebook-container .jp-RenderedText[data-mime-type="text/plain"] pre,
.jupyter-notebook-container .jp-RenderedText[data-mime-type="application/vnd.jupyter.stdout"] pre {
  background: var(--jp-layout-color1);
  border-color: var(--jp-border-color1);
  color: var(--jp-content-font-color1);
}

.jupyter-notebook-container .jp-RenderedText[data-mime-type="application/vnd.jupyter.stderr"] pre {
  background: var(--jp-error-color3);
  color: var(--jp-error-color0);
}

/* Tables */
.jupyter-notebook-container .jp-RenderedHTMLCommon table {
  border-color: var(--jp-border-color1);
}

.jupyter-notebook-container .jp-RenderedHTMLCommon td,
.jupyter-notebook-container .jp-RenderedHTMLCommon th {
  border: 1px solid var(--jp-border-color1);
  color: var(--jp-content-font-color1);
}

[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedHTMLCommon thead {
  background: var(--jp-layout-color2);
}

[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedHTMLCommon table {
  border-color: var(--jp-border-color0);
}

[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedHTMLCommon td,
[data-color-mode=dark] .jupyter-notebook-container .jp-RenderedHTMLCommon th {
  border-color: var(--jp-border-color0);
}
