.python-runtime {
  padding: 1rem 1.2rem;
  margin: 1.2rem 0;
  border: 1px solid var(--border-1);
  border-radius: 12px;
  background: var(--surface-1);
}
.python-runtime p { margin: 0 0 .6rem; }
.code-examples .python-cell-compact { border: 0; border-radius: 0; margin: 0; }
.python-cell-compact .python-cell-toolbar { justify-content: flex-end; padding: .4rem .6rem; }
.python-cell-compact .python-restore { background: none; border-color: transparent; color: var(--text-2); }
#python-download, #python-status, #python-type-status { font-size: .9rem; }
#python-status { color: var(--brand-strong); }
.python-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.python-runtime button, .python-cell button, #python-session-controls button {
  padding: .35rem .75rem;
  border: 1px solid var(--border-1);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-1);
  font: inherit;
  font-size: .875rem;
  cursor: pointer;
}
.python-cell .python-run, #python-session-controls #python-run-all {
  color: var(--brand-strong);
  border-color: var(--brand);
  font-weight: 600;
}
#python-session-controls { margin: 0 0 1rem; font-size: .875rem; color: var(--text-2); }
#python-session-controls button + button { margin-left: .5rem; }
.python-runtime button:disabled, .python-cell button:disabled, #python-session-controls button:disabled { opacity: .55; cursor: default; }
.python-runtime button:focus-visible, .python-cell button:focus-visible, #python-session-controls button:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.python-cell { border: 1px solid var(--border-1); border-radius: 10px; overflow: hidden; margin-bottom: 1rem; }
.python-cell-toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: .5rem; padding: .6rem .8rem; border-top: 1px solid var(--border-1); font-size: .875rem; color: var(--text-2); }
.python-editor { min-width: 0; --selection-bg: #b3d8ef80; }
.python-editor .cm-editor { max-width: 100%; }
.python-editor .cm-scroller { max-height: 32rem; }
.python-editor .cm-focused { outline: 2px solid var(--brand); outline-offset: -2px; }
.python-editor .cm-content::selection, .python-editor .cm-content ::selection { color: inherit; }
.python-output-region { border-top: 1px solid var(--border-1); padding: .7rem .8rem; background: var(--surface-1); }
/* The live result replaces the shared static output while Python is selected.
   Switching to Rust still shows the original expected output. */
.panel-tabset:has(.tab-pane.active .python-output-region:not([hidden])) + .symbolica-output { display: none; }
.python-result { color: var(--text-2); font-size: .875rem; margin-bottom: .4rem; }
.python-output { max-height: 24rem; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: .9rem/1.6 var(--bs-font-monospace); }
.python-error { color: #b02a37; }
body.quarto-dark .python-error { color: #ff9b9b; }
/* Match the static Python code overrides in styles.css. Light mode inherits
   Quarto's syntax palette directly, including changes to the site theme. */
body.quarto-dark .python-editor {
  --selection-bg: color-mix(in srgb, var(--brand) 20%, var(--surface-1));
  --python-code-color: #dbe7f3;
  --quarto-hl-co-color: #93a7bb;
  --quarto-hl-im-color: #8fd3c1;
  --quarto-hl-st-color: #8fd3c1;
  --quarto-hl-sc-color: #8fd3c1;
  --quarto-hl-kw-color: #f0b48a;
  --quarto-hl-op-color: #f0b48a;
  --quarto-hl-fu-color: #f0b48a;
  --quarto-hl-dt-color: #f0b48a;
  --quarto-hl-cn-color: #84b8ff;
  --quarto-hl-at-color: #84b8ff;
  --quarto-hl-dv-color: #d8c28f;
}
.python-output .rich-result { white-space: normal; }
.python-cell[aria-busy="true"] { border-color: var(--brand); }

.type-hint { max-width: min(620px, 85vw); padding: .75rem 1rem; color: var(--text-1); }
.type-hint-title { font: 600 .875rem/1.5 system-ui, sans-serif; color: var(--brand-strong); margin-bottom: .5rem; }
.type-hint-body { white-space: normal; max-height: min(380px, 55vh); overflow: auto; font: .875rem/1.6 system-ui, sans-serif; overflow-wrap: anywhere; }
.type-hint-body > :first-child { margin-top: 0; }
.type-hint-body > :last-child { margin-bottom: 0; }
.type-hint-body p { margin: .6rem 0; }
.type-hint-body :is(h1, h2, h3, h4, h5, h6) { font: 650 .9rem/1.5 system-ui, sans-serif; margin: 1rem 0 .4rem; border: 0; padding: 0; }
.type-hint-body code { font: .875rem/1.6 var(--bs-font-monospace); background: var(--surface-2); color: var(--text-1); padding: 1px 4px; border-radius: 3px; }
.type-hint-body pre { background: var(--surface-2); color: var(--python-code-color, var(--quarto-hl-ot-color)); border-radius: 6px; padding: .6rem .75rem; margin: .6rem 0; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.type-hint-body pre code { background: none; padding: 0; color: inherit; }
.type-hint-body ul, .type-hint-body ol { padding-left: 1.5rem; margin: .5rem 0; }
.type-hint-body blockquote { border-left: 3px solid var(--brand); padding-left: .6rem; margin: .6rem 0; }
.type-hint-body table { border-collapse: collapse; margin: .6rem 0; }
.type-hint-body th, .type-hint-body td { border: 1px solid var(--border-1); padding: .3rem .5rem; text-align: left; }
.cm-tooltip-autocomplete { max-width: calc(100vw - 32px); font: .875rem/1.6 var(--bs-font-monospace); }
.python-editor .cm-tooltip.cm-tooltip-autocomplete > ul { width: min(620px, calc(100vw - 32px)); min-width: 0; max-width: 100%; height: auto; max-height: min(280px, 40vh); padding: 4px 0; }
.python-editor .cm-tooltip.cm-tooltip-autocomplete > ul > li[role=option] { display: grid; grid-template-columns: 16px minmax(100px, 175px) minmax(0, 1fr); align-items: center; gap: 8px; padding: 5px 10px; line-height: 1.6; }
.cm-tooltip-autocomplete .cm-completionLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.python-editor code.cm-completionSignature { display: block; min-width: 0; padding: 0; background: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font: inherit; color: var(--python-code-color, var(--quarto-hl-ot-color)); }
.python-editor .cm-tooltip-autocomplete > ul > li[aria-selected] { background: var(--surface-2); color: var(--text-1); }
.python-editor .cm-tooltip.cm-completionInfo { padding: 0; white-space: normal; }
.type-hint-plain { white-space: pre-wrap; }
