/**
 * Компонент Python Sandbox (Pyodide) — общий для всех app
 * Neuronis
 */

/*
 * Подсказки автодополнения CodeMirror — стеклянная панель, мягкие тени, градиент у активного пункта.
 * ul. — выше специфичность, чем у vendor/show-hint.css (он подключается позже).
 */
ul.CodeMirror-hints {
  z-index: 12000;
  box-sizing: border-box;
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
  max-height: 16rem;
  overflow-x: hidden;
  overflow-y: auto;
  border-radius: 14px;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.45;
  letter-spacing: -0.015em;
}

ul.CodeMirror-hints::-webkit-scrollbar {
  width: 6px;
}

ul.CodeMirror-hints::-webkit-scrollbar-thumb {
  border-radius: 99px;
}

[data-theme="dark"] ul.CodeMirror-hints::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] ul.CodeMirror-hints {
  background: rgba(22, 25, 31, 0.92);
  border: 1px solid rgba(167, 139, 250, 0.28);
  color: #e8edf4;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.4),
    0 16px 48px rgba(0, 0, 0, 0.55),
    0 0 64px rgba(139, 92, 246, 0.12);
  backdrop-filter: blur(16px) saturate(1.2);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

[data-theme="dark"] ul.CodeMirror-hints li.CodeMirror-hint {
  margin: 3px 8px;
  padding: 0.44rem 0.7rem !important;
  border-radius: 10px;
  color: #e2e8f0 !important;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease,
    color 0.14s ease;
}

[data-theme="dark"] ul.CodeMirror-hints li.CodeMirror-hint:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(255, 255, 255, 0.06);
}

[data-theme="dark"] ul.CodeMirror-hints li.CodeMirror-hint-active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.28) 0%, rgba(5, 184, 125, 0.2) 100%) !important;
  border-color: rgba(167, 139, 250, 0.45);
  color: #fff !important;
  box-shadow:
    0 0 0 1px rgba(5, 184, 125, 0.35),
    0 6px 18px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] ul.CodeMirror-hints::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.14);
}

[data-theme="light"] ul.CodeMirror-hints {
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid rgba(139, 92, 246, 0.22);
  color: #0f172a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 14px 44px rgba(15, 23, 42, 0.1),
    0 0 48px rgba(139, 92, 246, 0.08);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  scrollbar-color: rgba(15, 23, 42, 0.22) transparent;
}

[data-theme="light"] ul.CodeMirror-hints li.CodeMirror-hint {
  margin: 3px 8px;
  padding: 0.44rem 0.7rem !important;
  border-radius: 10px;
  color: #0f172a !important;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}

[data-theme="light"] ul.CodeMirror-hints li.CodeMirror-hint:hover {
  background: rgba(15, 23, 42, 0.04);
  border-color: rgba(15, 23, 42, 0.06);
}

[data-theme="light"] ul.CodeMirror-hints li.CodeMirror-hint-active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.16) 0%, rgba(5, 184, 125, 0.12) 100%) !important;
  border-color: rgba(5, 184, 125, 0.4);
  color: #020617 !important;
  box-shadow: 0 4px 14px rgba(5, 184, 125, 0.12);
}

.python-sandbox {
  --sandbox-font-size: 20px;
  --sandbox-font: "Fira Code", "JetBrains Mono", "Consolas", monospace;
  /* Как фон области кода CodeMirror darcula (.cm-s-darcula.CodeMirror) */
  --sandbox-shell-bg: #2b2b2b;
  --sandbox-shell-fg: #a9b7c6;
  --sandbox-shell-gutter-border: rgba(255, 255, 255, 0.12);
  --sandbox-shell-prompt-color: #da7756;
  position: relative;
  display: flex;
  flex-direction: column;
  background: #1e2228;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
  min-height: 320px;
}

/* Редактор + resizer + shell на всю высоту колонки (task 2) */
.python-sandbox.python-sandbox--split-shell {
  flex: 1 1 auto;
  min-height: 0;
}

.python-sandbox--split-shell .python-sandbox__split-root {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.python-sandbox--split-shell .python-sandbox__editor-pane[hidden] {
  display: none !important;
}

.python-sandbox--split-shell .python-sandbox__split-root > #video-view.task-video-view--chromeless {
  display: flex;
  flex-direction: column;
  min-height: 100px;
  min-width: 0;
  overflow: hidden;
}

.python-sandbox--split-shell .python-sandbox__split-root > #video-view.task-video-view--chromeless:not([hidden]) .video-view__player {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  aspect-ratio: unset;
  height: 100%;
  max-height: 100%;
  background: #000;
}

.python-sandbox--split-shell .python-sandbox__split-root > #video-view.task-video-view--chromeless .video-view__iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: none;
}

.python-sandbox--split-shell .python-sandbox__splitter[hidden] {
  display: none !important;
}

.python-sandbox--split-shell .python-sandbox__editor-pane {
  display: flex;
  flex-direction: column;
  flex: 1 1 50%;
  min-height: 100px;
  overflow: hidden;
}

.python-sandbox--split-shell .python-sandbox__editor-pane .python-sandbox__editor-wrap {
  flex: 1 1 auto;
  min-height: 0;
}

.python-sandbox--split-shell .python-sandbox__editor-pane .python-sandbox__panel {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  min-width: 0;
}

.python-sandbox--split-shell .python-sandbox__editor-wrap .CodeMirror {
  height: 100%;
}

.python-sandbox--split-shell .python-sandbox__editor-wrap .CodeMirror-scroll {
  min-height: 0;
}

.python-sandbox--split-shell .python-sandbox__editor {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  resize: none;
}

.python-sandbox__splitter {
  flex: 0 0 6px;
  margin: 0;
  padding: 0;
  cursor: ns-resize;
  touch-action: none;
  background: rgba(255, 255, 255, 0.06);
  border: solid rgba(255, 255, 255, 0.1);
  border-width: 1px 0;
  box-sizing: border-box;
}

.python-sandbox__splitter:hover {
  background: rgba(5, 184, 125, 0.2);
}

.python-sandbox__splitter:focus-visible {
  outline: 2px solid var(--green, #05b87d);
  outline-offset: -1px;
}

.python-sandbox--split-shell .python-sandbox__output-stack {
  display: flex;
  flex-direction: column;
  flex: 1 1 50%;
  min-height: 72px;
  overflow: hidden;
}

/* Embed варианта КИМ (/variants/.../taskN/embed): редактор 80%, консоль 20% */
body.variant-trainer-embed-body .python-sandbox--split-shell .python-sandbox__editor-pane {
  flex: 0 0 80%;
  min-height: 100px;
}

body.variant-trainer-embed-body .python-sandbox--split-shell .python-sandbox__output-stack {
  flex: 0 0 20%;
  min-height: 72px;
}

/* Save As — диалог (стекло, акценты как у подсказок CodeMirror) */
.python-sandbox-save-as-modal {
  position: fixed;
  inset: 0;
  z-index: 12100;
  display: grid;
  place-items: center;
  padding: max(12px, 2.5vmin);
  box-sizing: border-box;
}

/* Оконный режим IDLE: центр относительно #python-sandbox-win-container (половина экрана / колонка), не всего вьюпорта */
.python-sandbox-win-container .python-sandbox-save-as-modal {
  position: absolute;
}

.python-sandbox-save-as-modal[hidden] {
  display: none !important;
}

.python-sandbox-save-as-modal__scrim {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  background: linear-gradient(165deg, rgba(15, 23, 42, 0.62) 0%, rgba(30, 27, 75, 0.45) 100%);
  backdrop-filter: blur(10px) saturate(1.15);
  -webkit-backdrop-filter: blur(10px) saturate(1.15);
  cursor: pointer;
}

.python-sandbox-save-as-modal__panel {
  --save-as-radius: 16px;
  --save-as-green: #05b87d;
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: min(96vw, 440px);
  padding: 0;
  border-radius: var(--save-as-radius);
  border: 1px solid rgba(167, 139, 250, 0.32);
  background: rgba(22, 25, 31, 0.94);
  color: #e8edf4;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 24px 56px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(139, 92, 246, 0.1);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  outline: none;
  overflow: hidden;
}

.python-sandbox-save-as-modal__panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    rgba(139, 92, 246, 0.95) 0%,
    rgba(5, 184, 125, 0.85) 55%,
    rgba(52, 211, 153, 0.65) 100%
  );
  pointer-events: none;
}

.python-sandbox-save-as-modal__head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.15rem 1.25rem 0.85rem;
}

.python-sandbox-save-as-modal__head-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  color: #c4b5fd;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.22) 0%, rgba(5, 184, 125, 0.12) 100%);
  border: 1px solid rgba(167, 139, 250, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.python-sandbox-save-as-modal__head-svg {
  width: 1.35rem;
  height: 1.35rem;
  opacity: 0.95;
}

.python-sandbox-save-as-modal__head-text {
  min-width: 0;
  flex: 1;
}

.python-sandbox-save-as-modal__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #f8fafc;
}

.python-sandbox-save-as-modal__lede {
  margin: 0.28rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(226, 232, 240, 0.55);
}

.python-sandbox-save-as-modal__body {
  padding: 0 1.25rem 1rem;
}

.python-sandbox-save-as-modal__field-label {
  display: block;
  margin-top: 0.15rem;
  margin-bottom: 0.4rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(203, 213, 225, 0.72);
}

.python-sandbox-save-as-modal__input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.45;
  letter-spacing: -0.02em;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.python-sandbox-save-as-modal__input::placeholder {
  color: rgba(148, 163, 184, 0.45);
}

.python-sandbox-save-as-modal__input:hover {
  border-color: rgba(167, 139, 250, 0.35);
}

.python-sandbox-save-as-modal__input:focus {
  outline: none;
  border-color: rgba(5, 184, 125, 0.55);
  box-shadow:
    0 0 0 3px rgba(5, 184, 125, 0.18),
    0 0 24px rgba(139, 92, 246, 0.12);
  background: rgba(15, 23, 42, 0.85);
}

.python-sandbox-save-as-modal__checks {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.python-sandbox-save-as-modal__check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: min(100%, 8.5rem);
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.8125rem;
  line-height: 1.3;
  cursor: pointer;
  color: rgba(226, 232, 240, 0.9);
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    box-shadow 0.14s ease;
}

.python-sandbox-save-as-modal__check:hover {
  background: rgba(255, 255, 255, 0.055);
  border-color: rgba(167, 139, 250, 0.28);
}

.python-sandbox-save-as-modal__check:has(input:checked) {
  border-color: rgba(167, 139, 250, 0.5);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(5, 184, 125, 0.12) 100%);
  box-shadow: 0 0 0 1px rgba(5, 184, 125, 0.22);
}

.python-sandbox-save-as-modal__check input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--save-as-green, #05b87d);
  cursor: pointer;
}

.python-sandbox-save-as-modal__check-text {
  font-weight: 500;
  letter-spacing: -0.01em;
}

.python-sandbox-save-as-modal__recent {
  margin-bottom: 0.85rem;
}

.python-sandbox-save-as-modal__recent-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.45rem;
}

.python-sandbox-save-as-modal__recent-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(203, 213, 225, 0.72);
}

.python-sandbox-save-as-modal__recent-hint {
  font-size: 0.6875rem;
  color: rgba(148, 163, 184, 0.65);
}

.python-sandbox-save-as-modal__recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.32rem;
  overflow-x: hidden;
  overflow-y: visible;
  padding: 0.15rem 0;
  margin: 0 -0.15rem;
}

.python-sandbox-save-as-modal__recent-item {
  flex-shrink: 0;
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 0.38rem 0.55rem;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.45);
  font: inherit;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.python-sandbox-save-as-modal__recent-item:hover {
  border-color: rgba(167, 139, 250, 0.4);
  background: rgba(139, 92, 246, 0.12);
  color: #f8fafc;
}

.python-sandbox-save-as-modal__recent-item:focus-visible {
  outline: none;
  border-color: rgba(5, 184, 125, 0.55);
  box-shadow: 0 0 0 2px rgba(5, 184, 125, 0.22);
}

.python-sandbox-save-as-modal__recent-empty {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(148, 163, 184, 0.55);
}

.python-sandbox-save-as-modal__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0;
  padding: 0.85rem 1.25rem 1.15rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(0, 0, 0, 0.12);
}

.python-sandbox-save-as-modal__btn {
  padding: 0.48rem 1rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(255, 255, 255, 0.06);
  color: #e8edf4;
  transition:
    background 0.14s ease,
    border-color 0.14s ease,
    transform 0.12s ease;
}

.python-sandbox-save-as-modal__btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(203, 213, 225, 0.35);
}

.python-sandbox-save-as-modal__btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.35);
}

.python-sandbox-save-as-modal__btn:active {
  transform: scale(0.98);
}

.python-sandbox-save-as-modal__btn--primary {
  border-color: rgba(5, 184, 125, 0.55);
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.35) 0%, rgba(16, 185, 129, 0.22) 100%);
  color: #ecfdf5;
  box-shadow: 0 4px 16px rgba(5, 184, 125, 0.18);
}

.python-sandbox-save-as-modal__btn--primary:hover {
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.45) 0%, rgba(16, 185, 129, 0.3) 100%);
  border-color: rgba(52, 211, 153, 0.65);
}

.python-sandbox-save-as-modal__btn--primary:focus-visible {
  box-shadow:
    0 0 0 3px rgba(5, 184, 125, 0.28),
    0 4px 16px rgba(5, 184, 125, 0.2);
}

[data-theme="light"] .python-sandbox-save-as-modal__scrim {
  background: linear-gradient(165deg, rgba(15, 23, 42, 0.35) 0%, rgba(79, 70, 229, 0.12) 100%);
}

[data-theme="light"] .python-sandbox-save-as-modal__panel {
  border-color: rgba(139, 92, 246, 0.28);
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 20px 50px rgba(15, 23, 42, 0.12),
    0 0 60px rgba(139, 92, 246, 0.08);
}

[data-theme="light"] .python-sandbox-save-as-modal__head-icon {
  color: #6d28d9;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.12) 0%, rgba(5, 184, 125, 0.08) 100%);
  border-color: rgba(139, 92, 246, 0.28);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .python-sandbox-save-as-modal__title {
  color: #020617;
}

[data-theme="light"] .python-sandbox-save-as-modal__lede {
  color: #64748b;
}

[data-theme="light"] .python-sandbox-save-as-modal__field-label {
  color: #64748b;
}

[data-theme="light"] .python-sandbox-save-as-modal__input {
  color: #0f172a;
  background: rgba(248, 250, 252, 0.95);
  border-color: rgba(15, 23, 42, 0.12);
}

[data-theme="light"] .python-sandbox-save-as-modal__input:hover {
  border-color: rgba(139, 92, 246, 0.35);
}

[data-theme="light"] .python-sandbox-save-as-modal__input:focus {
  border-color: rgba(5, 184, 125, 0.55);
  box-shadow:
    0 0 0 3px rgba(5, 184, 125, 0.15),
    0 0 28px rgba(139, 92, 246, 0.08);
  background: #fff;
}

[data-theme="light"] .python-sandbox-save-as-modal__check {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.03);
  color: #334155;
}

[data-theme="light"] .python-sandbox-save-as-modal__check:hover {
  background: rgba(15, 23, 42, 0.05);
  border-color: rgba(139, 92, 246, 0.22);
}

[data-theme="light"] .python-sandbox-save-as-modal__check:has(input:checked) {
  border-color: rgba(5, 184, 125, 0.45);
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.1) 0%, rgba(5, 184, 125, 0.08) 100%);
  box-shadow: 0 0 0 1px rgba(5, 184, 125, 0.2);
}

[data-theme="light"] .python-sandbox-save-as-modal__recent-title {
  color: #64748b;
}

[data-theme="light"] .python-sandbox-save-as-modal__recent-hint {
  color: #94a3b8;
}

[data-theme="light"] .python-sandbox-save-as-modal__recent-item {
  border-color: rgba(15, 23, 42, 0.1);
  background: rgba(248, 250, 252, 0.95);
  color: #0f172a;
}

[data-theme="light"] .python-sandbox-save-as-modal__recent-item:hover {
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(139, 92, 246, 0.06);
  color: #020617;
}

[data-theme="light"] .python-sandbox-save-as-modal__recent-item:focus-visible {
  border-color: rgba(5, 184, 125, 0.55);
  box-shadow: 0 0 0 2px rgba(5, 184, 125, 0.18);
}

[data-theme="light"] .python-sandbox-save-as-modal__recent-empty {
  color: #94a3b8;
}

[data-theme="light"] .python-sandbox-save-as-modal__actions {
  border-top-color: rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.03);
}

[data-theme="light"] .python-sandbox-save-as-modal__btn {
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}

[data-theme="light"] .python-sandbox-save-as-modal__btn:hover {
  background: #e2e8f0;
  border-color: rgba(15, 23, 42, 0.18);
}

[data-theme="light"] .python-sandbox-save-as-modal__btn--primary {
  border-color: rgba(5, 184, 125, 0.5);
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.28) 0%, rgba(16, 185, 129, 0.18) 100%);
  color: #065f46;
  box-shadow: 0 4px 14px rgba(5, 184, 125, 0.15);
}

[data-theme="light"] .python-sandbox-save-as-modal__btn--primary:hover {
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.38) 0%, rgba(16, 185, 129, 0.26) 100%);
}

/* input(): компактный ввод — только поверх Python-тренажёра, без затемнения всей страницы */
.python-sandbox-stdin-modal {
  position: fixed;
  inset: 0;
  z-index: 12150;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  box-sizing: border-box;
  pointer-events: none;
}

/* Оконный режим IDLE: только колонка тренажёра, не весь viewport */
.python-sandbox-win-container .python-sandbox-stdin-modal {
  position: absolute;
}

.python-sandbox-stdin-modal[hidden] {
  display: none !important;
}

.python-sandbox-stdin-modal__scrim {
  display: none;
}

.python-sandbox-stdin-modal__panel {
  --stdin-modal-radius: 16px;
  --stdin-green: #05b87d;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  width: 100%;
  max-width: min(96%, 420px);
  padding: 0;
  border-radius: var(--stdin-modal-radius);
  border: 1px solid rgba(5, 184, 125, 0.32);
  background: rgba(22, 25, 31, 0.94);
  color: #e8edf4;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.45),
    0 24px 56px rgba(0, 0, 0, 0.55),
    0 0 80px rgba(5, 184, 125, 0.1);
  backdrop-filter: blur(18px) saturate(1.2);
  -webkit-backdrop-filter: blur(18px) saturate(1.2);
  outline: none;
  overflow: hidden;
}

.python-sandbox-stdin-modal__panel::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    rgba(139, 92, 246, 0.95) 0%,
    rgba(5, 184, 125, 0.85) 55%,
    rgba(52, 211, 153, 0.65) 100%
  );
  pointer-events: none;
}

.python-sandbox-stdin-modal__head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.15rem 1.25rem 0.85rem;
}

.python-sandbox-stdin-modal__head-icon {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  color: #6ee7b7;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.22) 0%, rgba(5, 184, 125, 0.12) 100%);
  border: 1px solid rgba(5, 184, 125, 0.35);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.python-sandbox-stdin-modal__head-svg {
  width: 1.35rem;
  height: 1.35rem;
  opacity: 0.95;
}

.python-sandbox-stdin-modal__head-text {
  min-width: 0;
  flex: 1;
}

.python-sandbox-stdin-modal__title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: #f8fafc;
}

.python-sandbox-stdin-modal__lede {
  margin: 0.28rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: rgba(226, 232, 240, 0.72);
  white-space: pre-wrap;
  word-break: break-word;
}

.python-sandbox-stdin-modal__lede[hidden] {
  display: none !important;
}

.python-sandbox-stdin-modal__body {
  padding: 0 1.25rem 1rem;
}

.python-sandbox-stdin-modal__field-label {
  display: block;
  margin: 0 0 0.45rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.75);
}

.python-sandbox-stdin-modal__input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.65);
  font: inherit;
  font-family: "JetBrains Mono", "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9375rem;
  line-height: 1.4;
  color: #f1f5f9;
  outline: none;
  transition:
    border-color 0.12s ease,
    box-shadow 0.12s ease;
}

.python-sandbox-stdin-modal__input::placeholder {
  color: rgba(148, 163, 184, 0.45);
}

.python-sandbox-stdin-modal__input:hover {
  border-color: rgba(5, 184, 125, 0.35);
}

.python-sandbox-stdin-modal__input:focus {
  border-color: rgba(5, 184, 125, 0.55);
  box-shadow:
    0 0 0 3px rgba(5, 184, 125, 0.18),
    0 0 28px rgba(139, 92, 246, 0.08);
}

.python-sandbox-stdin-modal__actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 0;
  padding: 0.85rem 1.25rem 1.15rem;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  background: rgba(0, 0, 0, 0.12);
}

.python-sandbox-stdin-modal__btn {
  padding: 0.48rem 1rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.65);
  color: #e2e8f0;
  cursor: pointer;
  transition:
    background 0.12s ease,
    border-color 0.12s ease,
    color 0.12s ease;
}

.python-sandbox-stdin-modal__btn:hover {
  border-color: rgba(148, 163, 184, 0.38);
  background: rgba(51, 65, 85, 0.75);
  color: #f8fafc;
}

.python-sandbox-stdin-modal__btn--primary {
  border-color: rgba(5, 184, 125, 0.55);
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.35) 0%, rgba(16, 185, 129, 0.22) 100%);
  color: #ecfdf5;
  box-shadow: 0 4px 16px rgba(5, 184, 125, 0.18);
}

.python-sandbox-stdin-modal__btn--primary:hover {
  border-color: rgba(52, 211, 153, 0.55);
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.45) 0%, rgba(16, 185, 129, 0.3) 100%);
}

.python-sandbox-stdin-modal__btn--primary:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 3px rgba(5, 184, 125, 0.28),
    0 4px 16px rgba(5, 184, 125, 0.2);
}

[data-theme="light"] .python-sandbox-stdin-modal__panel {
  border-color: rgba(5, 184, 125, 0.28);
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.9) inset,
    0 20px 50px rgba(15, 23, 42, 0.12),
    0 0 60px rgba(5, 184, 125, 0.08);
}

[data-theme="light"] .python-sandbox-stdin-modal__head-icon {
  color: #059669;
  background: linear-gradient(145deg, rgba(139, 92, 246, 0.12) 0%, rgba(5, 184, 125, 0.08) 100%);
  border-color: rgba(5, 184, 125, 0.28);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

[data-theme="light"] .python-sandbox-stdin-modal__title {
  color: #0f172a;
}

[data-theme="light"] .python-sandbox-stdin-modal__lede {
  color: #475569;
}

[data-theme="light"] .python-sandbox-stdin-modal__input {
  background: rgba(248, 250, 252, 0.95);
  border-color: rgba(15, 23, 42, 0.12);
  color: #0f172a;
}

[data-theme="light"] .python-sandbox-stdin-modal__input:hover {
  border-color: rgba(5, 184, 125, 0.35);
}

[data-theme="light"] .python-sandbox-stdin-modal__input:focus {
  border-color: rgba(5, 184, 125, 0.55);
  box-shadow:
    0 0 0 3px rgba(5, 184, 125, 0.15),
    0 0 28px rgba(139, 92, 246, 0.08);
}

[data-theme="light"] .python-sandbox-stdin-modal__btn {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}

[data-theme="light"] .python-sandbox-stdin-modal__btn--primary {
  border-color: rgba(5, 184, 125, 0.5);
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.28) 0%, rgba(16, 185, 129, 0.18) 100%);
  color: #065f46;
  box-shadow: 0 4px 14px rgba(5, 184, 125, 0.15);
}

[data-theme="light"] .python-sandbox-stdin-modal__btn--primary:hover {
  background: linear-gradient(145deg, rgba(5, 184, 125, 0.38) 0%, rgba(16, 185, 129, 0.26) 100%);
}

/* Turtle (Pyodide): всплывающее окно поверх страницы */
.python-sandbox__turtle-modal {
  position: fixed;
  inset: 0;
  z-index: 12000;
  display: grid;
  place-items: center;
  padding: max(12px, 2.5vmin);
  box-sizing: border-box;
}

.python-sandbox__turtle-modal[hidden] {
  display: none !important;
}

.python-sandbox__turtle-modal-scrim {
  grid-area: 1 / 1;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
}

.python-sandbox__turtle-modal-panel {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  max-width: min(96vw, 920px);
  max-height: min(88vh, 900px);
  width: 100%;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #2b2b2b;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.35),
    0 24px 64px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  outline: none;
}

.python-sandbox__turtle-modal-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.45rem 0.45rem 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(0, 0, 0, 0.2);
}

/* Полоса заголовка в духе IDLE / Windows caption (светлый фон, тонкая верхняя граница окна). */
.python-sandbox__turtle-modal-header--idle {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  background: #f0f0f0;
  border-top: 1px solid #0a0a0a;
  border-bottom: 1px solid #a0a0a0;
}

.python-sandbox__turtle-modal-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(232, 237, 244, 0.92);
}

/* Как подпись в title bar Windows: Segoe UI ~12px, regular, чёрный. */
.python-sandbox__turtle-modal-header--idle .python-sandbox__turtle-modal-title {
  font-family: "Segoe UI", Tahoma, Verdana, system-ui, sans-serif;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.25;
  letter-spacing: normal;
  text-transform: none;
  color: #000000;
  -webkit-font-smoothing: antialiased;
}

.python-sandbox__turtle-modal-chrome {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.python-sandbox__turtle-modal-chrome-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 2px;
  color: #1a1a1a;
  background: transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.python-sandbox__turtle-modal-chrome-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.08);
}

.python-sandbox__turtle-modal-chrome-btn--close:hover {
  background: #e81123;
  border-color: #c50f1d;
  color: #fff;
}

.python-sandbox__turtle-modal-chrome-svg,
.python-sandbox__turtle-modal-chrome-icon {
  display: block;
  flex-shrink: 0;
}

.python-sandbox__turtle-modal-chrome-btn[data-turtle-modal-maximize] .python-sandbox__turtle-modal-chrome-icon--restore {
  display: none;
}

.python-sandbox__turtle-modal-chrome-btn[data-turtle-modal-maximize][aria-pressed="true"] .python-sandbox__turtle-modal-chrome-icon--max {
  display: none;
}

.python-sandbox__turtle-modal-chrome-btn[data-turtle-modal-maximize][aria-pressed="true"] .python-sandbox__turtle-modal-chrome-icon--restore {
  display: block;
}

.python-sandbox__turtle-modal--minimized .python-sandbox__turtle-modal-scrim {
  opacity: 0;
  pointer-events: none;
}

.python-sandbox__turtle-modal--minimized {
  align-items: flex-end;
  padding-bottom: 10px;
}

.python-sandbox__turtle-modal--minimized .python-sandbox__turtle-modal-panel {
  max-height: none;
  justify-self: center;
  width: min(480px, 94vw);
  max-width: min(480px, 94vw);
}

.python-sandbox__turtle-modal--minimized .python-sandbox__turtle-modal-body {
  display: none !important;
}

.python-sandbox__turtle-modal-panel--maximized {
  max-width: calc(100vw - 16px) !important;
  max-height: calc(100vh - 16px) !important;
  width: calc(100vw - 16px) !important;
  height: calc(100vh - 16px) !important;
  border-radius: 0;
}

/* Во весь экран: канвас занимает оставшееся место, SVG масштабируется пропорционально (contain). */
.python-sandbox__turtle-modal-panel--maximized .python-sandbox__turtle-modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.python-sandbox__turtle-modal-panel--maximized .python-sandbox__turtle-modal-zoom-mount > svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
}

.python-sandbox__turtle-modal-body {
  flex: 1 1 auto;
  min-height: 200px;
  overflow: auto;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  padding: 0.75rem;
}

.python-sandbox__turtle-modal-zoom-mount {
  display: inline-block;
  vertical-align: top;
}

.python-sandbox__turtle-modal-body svg {
  max-width: 100%;
  height: auto;
  display: block;
  background: #fff;
  border-radius: 6px;
}

html.neuroege-turtle-modal-open,
html.neuroege-turtle-modal-open body {
  overflow: hidden;
}

[data-theme="light"] .python-sandbox__turtle-modal-scrim {
  background: rgba(15, 23, 42, 0.4);
}

[data-theme="light"] .python-sandbox__turtle-modal-panel {
  background: #f8fafc;
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow:
    0 0 0 1px rgba(15, 23, 42, 0.06),
    0 24px 48px rgba(15, 23, 42, 0.18);
}

[data-theme="light"] .python-sandbox__turtle-modal-header {
  border-bottom-color: rgba(15, 23, 42, 0.1);
  background: rgba(255, 255, 255, 0.65);
}

[data-theme="light"] .python-sandbox__turtle-modal-header--idle {
  background: #f0f0f0;
  border-top-color: #0a0a0a;
  border-bottom-color: #a0a0a0;
}

[data-theme="light"] .python-sandbox__turtle-modal-title {
  color: #0f172a;
}

[data-theme="light"] .python-sandbox__turtle-modal-header--idle .python-sandbox__turtle-modal-title {
  color: #000000;
}

[data-theme="light"] .python-sandbox__turtle-modal-chrome-btn {
  color: #1e293b;
}

[data-theme="light"] .python-sandbox__turtle-modal-chrome-btn:hover {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.1);
}

.python-sandbox--split-shell .python-sandbox__toolbar {
  flex-shrink: 0;
  border-top: none;
}

.python-sandbox--split-shell .python-sandbox__shell {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  border-top: none;
}

/* Обёртка как окно IDLE + те же режимы сетки, что Calc на HF (univer-calc--restored / maximize / statement fullscreen) */
.python-sandbox-win-container {
  --idle-chrome-bg: #2b2b2b;
  --idle-chrome-bg-elev: #32353b;
  --idle-chrome-fg: #c8d0d8;
  --idle-chrome-fg-muted: rgba(200, 208, 216, 0.72);
  --idle-chrome-border: rgba(255, 255, 255, 0.1);
  --idle-chrome-hover: rgba(255, 255, 255, 0.08);
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-sizing: border-box;
}

.python-sandbox-win-container .python-sandbox {
  flex: 1 1 auto;
  min-height: 0;
  border-radius: 0;
  border: none;
}

/* IDLE titlebar + File menubar: тёмный chrome по умолчанию; на light — как окно кода (CM eclipse, белый холст) */
[data-theme="light"] .python-sandbox-win-container {
  --idle-chrome-bg: #ffffff;
  --idle-chrome-bg-elev: #ffffff;
  --idle-chrome-fg: #1a1a1a;
  --idle-chrome-fg-muted: rgba(0, 0, 0, 0.52);
  --idle-chrome-border: rgba(0, 0, 0, 0.1);
  --idle-chrome-hover: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox-idle-winbtn:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .python-sandbox-idle-menubar .python-sandbox__font-btn:hover {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
  color: var(--idle-chrome-fg);
}

[data-theme="light"] .python-sandbox-idle-menubar .python-sandbox__data-tab:hover {
  border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .python-sandbox-idle-menubar .python-sandbox__data-tab--active {
  color: #047857;
  border-color: rgba(5, 184, 125, 0.45);
  background: rgba(5, 184, 125, 0.12);
}

[data-theme="light"] .python-sandbox-win-container .python-sandbox-idle-menubar .task-9-script-toggle__icon-btn:hover {
  border-color: rgba(0, 0, 0, 0.2);
  background: rgba(0, 0, 0, 0.08);
  color: var(--idle-chrome-fg);
}

[data-theme="light"] .python-sandbox-win-container .python-sandbox-idle-menubar .task-9-script-toggle__icon-btn--active {
  color: #047857;
  border-color: rgba(5, 184, 125, 0.45);
  background: rgba(5, 184, 125, 0.12);
}

[data-theme="light"] .python-sandbox-idle-menudrop__panel {
  box-shadow: 1px 3px 10px rgba(0, 0, 0, 0.16);
}

[data-theme="light"] .python-sandbox-idle-menudrop__kbd {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .python-sandbox-idle-menubar .python-sandbox__run--menubar {
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.python-sandbox-idle-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-shrink: 0;
  padding: 0.35rem 0.45rem 0.35rem 0.65rem;
  background: var(--idle-chrome-bg);
  border-bottom: none;
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  color: var(--idle-chrome-fg);
}

.python-sandbox-idle-titlebar__title {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.python-sandbox-idle-titlebar__actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.python-sandbox-idle-winbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.35rem;
  padding: 0;
  margin: 0;
  border: 1px solid var(--idle-chrome-border);
  border-radius: 2px;
  background: var(--idle-chrome-hover);
  color: var(--idle-chrome-fg);
  font-size: 0.75rem;
  line-height: 1;
  cursor: pointer;
  box-sizing: border-box;
}

.python-sandbox-idle-winbtn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.18);
}

.python-sandbox-idle-winbtn:focus-visible {
  outline: 2px solid var(--green, #05b87d);
  outline-offset: 1px;
}

.python-sandbox-idle-winbtn--max {
  padding: 0.2rem;
}

.python-sandbox-idle-winbtn__svg {
  display: block;
  width: 0.7rem;
  height: 0.7rem;
}

.python-sandbox-idle-menubar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 0.15rem 0.45rem 0.2rem;
  background: var(--idle-chrome-bg);
  border-bottom: 1px solid var(--idle-chrome-border);
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  color: var(--idle-chrome-fg);
}

.python-sandbox-idle-menubar__left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.2rem;
  min-width: 0;
}

.python-sandbox-idle-menubar__right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
}

.python-sandbox-idle-menubar__font-controls.python-sandbox__font-controls {
  gap: 0.2rem;
}

.python-sandbox-idle-menubar .python-sandbox__font-btn {
  color: var(--idle-chrome-fg);
  border-color: var(--idle-chrome-border);
  background: var(--idle-chrome-hover);
}

.python-sandbox-idle-menubar .python-sandbox__font-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.python-sandbox-idle-menubar .python-sandbox__data-tab {
  border-color: var(--idle-chrome-border);
  color: var(--idle-chrome-fg-muted);
}

.python-sandbox-idle-menubar .python-sandbox__data-tab:hover {
  color: var(--idle-chrome-fg);
  border-color: rgba(255, 255, 255, 0.22);
}

.python-sandbox-idle-menubar .python-sandbox__data-tab--active {
  color: #6ee7b7;
  border-color: rgba(5, 184, 125, 0.55);
  background: rgba(5, 184, 125, 0.14);
}

/* «# комменты» в menubar (task 9/22/26) — в тон тёмному chrome */
.python-sandbox-win-container .python-sandbox-idle-menubar .task-9-script-toggle__icon-btn {
  border-color: var(--idle-chrome-border);
  background: var(--idle-chrome-hover);
  color: var(--idle-chrome-fg-muted);
}

.python-sandbox-win-container .python-sandbox-idle-menubar .task-9-script-toggle__icon-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.12);
  color: var(--idle-chrome-fg);
}

.python-sandbox-win-container .python-sandbox-idle-menubar .task-9-script-toggle__icon-btn--active {
  color: #6ee7b7;
  border-color: rgba(5, 184, 125, 0.55);
  background: rgba(5, 184, 125, 0.14);
}

.python-sandbox-idle-menuitem {
  padding: 0.12rem 0.35rem;
  color: inherit;
  user-select: none;
}

.python-sandbox-idle-menuitem--run {
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  border-radius: 3px;
}

.python-sandbox-idle-menuitem--run:hover {
  background: var(--idle-chrome-hover);
}

/* Выпадающее меню File (только вёрстка, без логики действий) */
.python-sandbox-idle-menudrop {
  position: relative;
  display: inline-block;
}

.python-sandbox-idle-menudrop__summary {
  list-style: none;
  cursor: default;
}

.python-sandbox-idle-menudrop__summary::-webkit-details-marker {
  display: none;
}

.python-sandbox-idle-menudrop[open] > .python-sandbox-idle-menudrop__summary {
  background: var(--idle-chrome-hover);
  border-radius: 3px;
}

.python-sandbox-idle-menudrop__panel {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 2px;
  min-width: 17.5rem;
  padding: 0.125rem 0;
  background: var(--idle-chrome-bg-elev);
  border: 1px solid var(--idle-chrome-border);
  border-radius: 2px;
  box-shadow: 2px 4px 14px rgba(0, 0, 0, 0.45);
  z-index: 200;
  font-size: 0.8125rem;
  color: var(--idle-chrome-fg);
  overflow: visible;
}

.python-sandbox-idle-menudrop__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.14rem 0.75rem 0.14rem 0.6rem;
  line-height: 1.2;
  white-space: nowrap;
}

.python-sandbox-idle-menudrop__row:hover {
  background: rgba(5, 184, 125, 0.16);
}

.python-sandbox-idle-menudrop__row--action {
  width: 100%;
  border: none;
  background: transparent;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.python-sandbox-open-file-input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.python-sandbox-idle-menudrop__label {
  flex: 1;
  min-width: 0;
}

.python-sandbox-idle-menudrop__kbd {
  font-family: ui-monospace, "Cascadia Mono", "Consolas", monospace;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.15;
  color: var(--idle-chrome-fg-muted);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--idle-chrome-border);
  border-radius: 2px;
  padding: 0.04rem 0.28rem;
}

.python-sandbox-idle-menudrop__sep {
  height: 1px;
  margin: 0.1rem 0.35rem;
  background: var(--idle-chrome-border);
  border: none;
}

/* Recent Files — подменю справа как в IDLE / классических меню Windows */
.python-sandbox-idle-flyout {
  position: relative;
  z-index: 1;
}

.python-sandbox-idle-flyout:hover,
.python-sandbox-idle-flyout:focus-within {
  z-index: 220;
}

.python-sandbox-idle-flyout__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.14rem 0.75rem 0.14rem 0.6rem;
  line-height: 1.2;
  white-space: nowrap;
  cursor: default;
  user-select: none;
  font-size: 0.8125rem;
  color: var(--idle-chrome-fg);
}

.python-sandbox-idle-flyout__caret {
  flex-shrink: 0;
  font-size: 0.65rem;
  opacity: 0.85;
  margin-left: 0.35rem;
}

.python-sandbox-idle-flyout:hover .python-sandbox-idle-flyout__trigger,
.python-sandbox-idle-flyout:focus-within .python-sandbox-idle-flyout__trigger {
  background: #316ac5;
  color: #fff;
}

.python-sandbox-idle-flyout:hover .python-sandbox-idle-flyout__caret,
.python-sandbox-idle-flyout:focus-within .python-sandbox-idle-flyout__caret {
  color: #fff;
  opacity: 1;
}

.python-sandbox-idle-flyout__panel {
  position: absolute;
  left: 100%;
  top: -0.125rem;
  margin-left: 1px;
  min-width: 11.5rem;
  max-width: 22rem;
  max-height: 12rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.125rem 0;
  background: #ececec;
  border: 1px solid #1a1a1a;
  border-radius: 0;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.25);
  z-index: 221;
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  color: #000;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.python-sandbox-idle-flyout:hover .python-sandbox-idle-flyout__panel,
.python-sandbox-idle-flyout:focus-within .python-sandbox-idle-flyout__panel {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.python-sandbox-idle-flyout__empty {
  padding: 0.12rem 0.65rem 0.14rem 0.65rem;
  font-size: 0.75rem;
  color: #444;
  white-space: normal;
}

.python-sandbox-idle-flyout__item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.1rem 0.65rem 0.1rem 0.55rem;
  line-height: 1.25;
  border: none;
  background: transparent;
  font: inherit;
  color: #000;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.python-sandbox-idle-flyout__item:hover,
.python-sandbox-idle-flyout__item:focus {
  background: #316ac5;
  color: #fff;
  outline: none;
}

[data-theme="light"] .python-sandbox-idle-flyout__panel {
  background: #f5f5f5;
  border-color: #333;
}

.python-sandbox__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__header-title {
  flex-shrink: 0;
}

.python-sandbox__header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.python-sandbox__header-tabs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.python-sandbox__data-tab {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.python-sandbox__data-tab:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.3);
}

.python-sandbox__data-tab--active {
  color: var(--green, #05b87d);
  background: rgba(5, 184, 125, 0.15);
  border-color: rgba(5, 184, 125, 0.4);
}

.python-sandbox__panel {
  display: flex;
  flex: 1;
  min-width: 0;
  width: 100%;
}

#python-sandbox-panel-py {
  align-items: stretch;
}

.python-sandbox__panel--hidden {
  display: none !important;
}

.python-sandbox__data-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  padding: 0.75rem 1rem;
  gap: 0.5rem;
}

.python-sandbox__txt {
  flex: 1;
  min-height: 176px;
  max-height: 400px;
  margin: 0;
  padding: 0.75rem;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  color: var(--white);
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
  overflow: auto;
  white-space: pre;
}

.python-sandbox__ods-wrap {
  flex: 1;
  min-height: 176px;
  max-height: 400px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.python-sandbox__ods-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.python-sandbox__ods-table th,
.python-sandbox__ods-table td {
  padding: 0.25rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  text-align: right;
}

.python-sandbox__ods-table th {
  background: rgba(0, 0, 0, 0.3);
  font-weight: 600;
  color: var(--text-muted);
}

.python-sandbox__ods-table td {
  color: var(--white);
}

.python-sandbox__copy-btn {
  align-self: flex-start;
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.python-sandbox__copy-btn:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.4);
}

.python-sandbox__editor-wrap {
  display: flex;
  flex: 0 0 auto;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

/* Два вертикальных редактора (один Pyodide, два черновика в Recent) */
.python-sandbox__editor-dual-grid {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
}

.python-sandbox__editor-dual-grid > .python-sandbox__dual-pane {
  flex: 1 1 0;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Специфичность .dual-pane { display:flex } перебивает стандартный [hidden] — без !important вторая колонка остаётся на экране */
.python-sandbox__editor-dual-grid > .python-sandbox__dual-pane[hidden],
.python-sandbox__dual-col-resizer[hidden] {
  display: none !important;
}

.python-sandbox__dual-pane > .python-sandbox__panel {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

.python-sandbox__dual-col-resizer {
  flex: 0 0 6px;
  cursor: ew-resize;
  align-self: stretch;
  background: rgba(255, 255, 255, 0.06);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__dual-col-resizer:hover {
  background: rgba(5, 184, 125, 0.15);
}

[data-theme="light"] .python-sandbox__dual-col-resizer {
  background: rgba(15, 23, 42, 0.06);
  border-left-color: rgba(15, 23, 42, 0.1);
  border-right-color: rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .python-sandbox__dual-col-resizer:hover {
  background: rgba(5, 184, 125, 0.12);
}

.python-sandbox-idle-winbtn--split[aria-pressed="true"] {
  color: #05b87d;
  border-color: rgba(5, 184, 125, 0.45);
}

.python-sandbox__editor-wrap .CodeMirror {
  flex: 1;
  min-width: 0;
  min-height: 0;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
}
.python-sandbox__editor-wrap .CodeMirror-gutters {
  background: rgba(0, 0, 0, 0.2);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__editor-wrap .CodeMirror .python-sandbox__error-line {
  background: rgba(248, 113, 113, 0.25) !important;
}
.python-sandbox__editor-wrap .CodeMirror-cursor {
  border-left-color: var(--white);
}

/* Замена оранжевой подсветки на зелёную #05b87d */
.python-sandbox__editor-wrap .CodeMirror span.cm-keyword,
.python-sandbox__editor-wrap .CodeMirror span.cm-link,
.python-sandbox__editor-wrap .CodeMirror span.cm-atom,
.python-sandbox__editor-wrap .CodeMirror span.cm-builtin,
.python-sandbox__editor-wrap .CodeMirror span.cm-special,
.python-sandbox__editor-wrap .CodeMirror span.cm-property,
.python-sandbox__editor-wrap .CodeMirror span.cm-meta {
  color: #05b87d !important;
}

/* Переменные — голубой, имена после def/class — жёлтый (режим Python CodeMirror) */
.python-sandbox__editor-wrap .CodeMirror span.cm-variable,
.python-sandbox__editor-wrap .CodeMirror span.cm-variable-3 {
  color: #7dd3fc !important;
}

.python-sandbox__editor-wrap .CodeMirror span.cm-variable-2 {
  color: #38bdf8 !important;
}

.python-sandbox__editor-wrap .CodeMirror span.cm-def {
  color: #fcd34d !important;
  font-style: normal;
}

.python-sandbox__lines {
  flex-shrink: 0;
  padding: 1rem 0.5rem 1rem 1rem;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.15);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  text-align: right;
  user-select: none;
  overflow-x: hidden;
  overflow-y: auto;
  white-space: pre;
}

.python-sandbox__editor {
  flex: 1;
  min-height: 180px;
  padding: 1rem;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  color: var(--white);
  background: transparent;
  border: none;
  resize: vertical;
  display: block;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.python-sandbox__editor:focus {
  outline: none;
}

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

.python-sandbox__toolbar {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  /* Как фон окна кода — без серой полоски в gap рядом с IDLE Shell */
  background: var(--sandbox-shell-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__shell-window-title {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: stretch;
  /* На всю высоту тулбара и цвет фона как у окна кода */
  margin: -0.5rem 0 -0.5rem -1rem;
  padding: 0.5rem 0.75rem 0.5rem 1rem;
  background: var(--sandbox-shell-bg);
  border: none;
  border-radius: 0;
  box-sizing: border-box;
}

/* Заголовок IDLE Shell — тот же фон/текст, что у CodeMirror */
.python-sandbox__status--idle-shell-title {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  padding: 0;
  margin: 0;
  font-family: system-ui, "Segoe UI", sans-serif;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--sandbox-shell-fg);
  background: transparent;
  border: none;
  border-radius: 0;
  box-sizing: border-box;
}

.python-sandbox__status--idle-shell-title.python-sandbox__status--message {
  font-weight: 500;
  color: var(--sandbox-shell-fg);
  background: transparent;
  opacity: 0.95;
}

.python-sandbox__status--idle-shell-title.python-sandbox__status--running {
  color: #05b87d;
  text-shadow: 0 0 14px rgba(5, 184, 125, 0.35);
  animation: python-sandbox-run-status-pulse 1.6s ease-in-out infinite;
  min-width: 9.5em;
}

@keyframes python-sandbox-run-status-pulse {
  0%,
  100% {
    opacity: 0.72;
  }
  50% {
    opacity: 1;
  }
}

[data-theme="light"] .python-sandbox__status--idle-shell-title.python-sandbox__status--running {
  color: #047857;
  text-shadow: none;
}

.python-sandbox__explain-audio {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 0.15rem;
  margin-left: auto;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(255, 255, 255, 0.1);
}

.python-sandbox__explain-audio[hidden] {
  display: none !important;
}

[data-theme="light"] .python-sandbox__explain-audio {
  border-left-color: rgba(0, 0, 0, 0.1);
}


.python-sandbox__toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  align-self: center;
  gap: 0.5rem;
}

.python-sandbox__action {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.python-sandbox__action-icon {
  display: block;
  flex-shrink: 0;
}

.python-sandbox__action:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.4);
}

.python-sandbox__run {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--bg);
  background: var(--green);
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.python-sandbox__run-icon {
  flex-shrink: 0;
}

.python-sandbox__run-icon--stop {
  display: none;
}

.python-sandbox__run--running .python-sandbox__run-icon--play {
  display: none;
}

.python-sandbox__run--running .python-sandbox__run-icon--stop {
  display: block;
}

.python-sandbox__run--running {
  background: #dc2626;
  color: #fff;
}

.python-sandbox__run:hover:not(:disabled) {
  opacity: 0.9;
}

.python-sandbox__run--running:hover:not(:disabled) {
  background: #b91c1c;
}

.python-sandbox__run:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.python-sandbox__run--running:disabled {
  opacity: 1;
  cursor: pointer;
}

.python-sandbox__run--menubar {
  padding: 0.22rem 0.55rem;
  min-height: 26px;
  min-width: 2rem;
  border-radius: 4px;
}

.python-sandbox-idle-menubar .python-sandbox__run--menubar {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.python-sandbox__status {
  min-width: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* Shell (IDLE-style): полоса слева; >>> сразу под последним выводом в потоке; общая прокрутка shell-scroll */
.python-sandbox__shell {
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow: hidden;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  color: var(--sandbox-shell-fg);
  background: var(--sandbox-shell-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__shell-scroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(169, 183, 198, 0.5) var(--sandbox-shell-bg);
}

/* Turtle: панель диагностики над транскриптом shell (вкл. data-turtle-live-diagnostics или ?turtle_diag=1) */
.python-sandbox__turtle-live-diagnostics {
  flex: 0 0 auto;
  max-height: 11rem;
  overflow: auto;
  padding: 0.45rem 0.65rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(5, 184, 125, 0.08);
  box-sizing: border-box;
}

.python-sandbox__turtle-live-diagnostics[hidden] {
  display: none !important;
}

.python-sandbox__turtle-live-diagnostics__head {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(232, 237, 244, 0.88);
  margin-bottom: 0.35rem;
}

.python-sandbox__turtle-live-diagnostics__pre {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.68rem;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  color: rgba(226, 232, 240, 0.95);
}

[data-theme="light"] .python-sandbox__turtle-live-diagnostics {
  background: rgba(5, 184, 125, 0.1);
  border-bottom-color: rgba(15, 23, 42, 0.1);
}

[data-theme="light"] .python-sandbox__turtle-live-diagnostics__head {
  color: #0f172a;
}

[data-theme="light"] .python-sandbox__turtle-live-diagnostics__pre {
  color: #1e293b;
}

.python-sandbox__shell-scroll::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.python-sandbox__shell-scroll::-webkit-scrollbar-track {
  background: var(--sandbox-shell-bg);
}

.python-sandbox__shell-scroll::-webkit-scrollbar-thumb {
  background: rgba(169, 183, 198, 0.45);
  border-radius: 5px;
  border: 2px solid var(--sandbox-shell-bg);
}

.python-sandbox__shell-body--grid {
  position: relative;
  display: grid;
  grid-template-columns: 2.65rem minmax(0, 1fr);
  grid-template-rows: auto auto auto;
  align-content: start;
  align-items: start;
  min-height: min-content;
}

/* Левая полоса: баннер + вывод + строка >>> */
.python-sandbox__shell-body--grid::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2.65rem;
  box-sizing: border-box;
  background: var(--sandbox-shell-bg);
  border-right: 1px solid var(--sandbox-shell-gutter-border);
  pointer-events: none;
  z-index: 0;
}

.python-sandbox__shell-body--grid > * {
  position: relative;
  z-index: 1;
}

.python-sandbox__shell-gutter-ph {
  grid-column: 1;
  background: transparent;
  pointer-events: none;
}

.python-sandbox__shell-gutter-ph--r1 {
  grid-row: 1;
}

.python-sandbox__shell-gutter-ph--r2 {
  grid-row: 2;
}

.python-sandbox__shell-banner--grid {
  grid-column: 2;
  grid-row: 1;
}

.python-sandbox__output--grid {
  grid-column: 1 / -1;
  grid-row: 2;
  height: min-content;
  min-height: min-content;
  align-self: start;
  box-sizing: border-box;
}

.python-sandbox__shell-prompt-mark {
  grid-column: 1;
  grid-row: 3;
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  box-sizing: border-box;
  padding: 0.1rem 0.25rem 0.35rem 0.5rem;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  color: var(--sandbox-shell-prompt-color);
  background: transparent;
  user-select: none;
}

.python-sandbox__shell-prompt {
  display: block;
  font-weight: 600;
  white-space: nowrap;
}

.python-sandbox__shell-prompt-rest--grid {
  grid-column: 2;
  grid-row: 3;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  background: var(--sandbox-shell-bg);
}

.python-sandbox__shell-repl-input {
  width: 100%;
  margin: 0;
  padding: 0.1rem 0 0.35rem;
  border: 0;
  outline: none;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  color: var(--sandbox-shell-fg);
  background: transparent;
  box-sizing: border-box;
}

.python-sandbox__shell-repl-input::placeholder {
  color: rgba(203, 213, 225, 0.4);
}

.python-sandbox__shell--stdin-mode .python-sandbox__shell-repl-input {
  background: rgba(5, 184, 125, 0.1);
  box-shadow: inset 0 0 0 1px rgba(5, 184, 125, 0.45);
}

.python-sandbox__shell--stdin-mode .python-sandbox__shell-prompt {
  color: var(--green, #05b87d);
}

/* В колонке под редактором — сетка shell растягивается по высоте */
.python-sandbox--split-shell .python-sandbox__shell-scroll {
  display: flex;
  flex-direction: column;
}

/* Без flex-grow лишней высоты — сетка по содержимому, прокрутка у shell-scroll */
.python-sandbox--split-shell .python-sandbox__shell-body--grid {
  flex: 0 1 auto;
  align-self: flex-start;
  width: 100%;
  box-sizing: border-box;
}

.python-sandbox__shell-banner {
  flex-shrink: 0;
  padding: 0.65rem 1rem 0.5rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--sandbox-shell-fg);
  background: var(--sandbox-shell-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.python-sandbox__shell-banner[hidden] {
  display: none !important;
}

.python-sandbox__output {
  max-height: 200px;
  overflow: auto;
  padding: 0.75rem 1rem;
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  color: var(--sandbox-shell-fg);
  background: var(--sandbox-shell-bg);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  white-space: pre-wrap;
  word-break: break-word;
  scrollbar-width: thin;
  scrollbar-color: rgba(169, 183, 198, 0.5) var(--sandbox-shell-bg);
}

.python-sandbox__output::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.python-sandbox__output::-webkit-scrollbar-track {
  background: var(--sandbox-shell-bg);
}

.python-sandbox__output::-webkit-scrollbar-thumb {
  background: rgba(169, 183, 198, 0.45);
  border-radius: 5px;
  border: 2px solid var(--sandbox-shell-bg);
}

.python-sandbox__output--transcript {
  max-height: none;
  min-height: 0;
  overflow: visible;
  background: var(--sandbox-shell-bg);
  padding-left: 0;
  border-top: none;
}

.python-sandbox__shell-row {
  display: grid;
  grid-template-columns: 2.65rem 1fr;
  column-gap: 0;
  align-items: start;
}

.python-sandbox__shell-row--legacy {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
}

.python-sandbox__shell-run-chunk--error {
  color: #f87171;
}

[data-theme="light"] .python-sandbox__shell-run-chunk--error {
  color: #dc2626;
}

.python-sandbox__shell-row-prompt {
  font-family: var(--sandbox-font);
  font-size: var(--sandbox-font-size);
  line-height: 1.5;
  font-weight: 600;
  color: var(--sandbox-shell-prompt-color);
  text-align: right;
  user-select: none;
  box-sizing: border-box;
  padding: 0.1rem 0.25rem 0.35rem 0.5rem;
}

.python-sandbox__shell-row-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.python-sandbox__shell-row--stdin .python-sandbox__shell-row-prompt {
  color: var(--green, #05b87d);
}

.python-sandbox__output:empty {
  display: none;
}

.python-sandbox__output.error {
  color: #f87171;
}

.python-sandbox__font-controls {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  margin-left: auto;
}

.python-sandbox__font-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.5rem;
  height: 26px;
  padding: 0 0.4rem;
  font-family: var(--sandbox-font);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
  user-select: none;
}

.python-sandbox__font-btn:hover {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.05);
}

[data-theme="light"] .python-sandbox__font-btn {
  color: rgba(0, 0, 0, 0.5);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .python-sandbox__font-btn:hover {
  color: inherit;
  border-color: rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.05);
}

/* Светлая тема */
[data-theme="light"] .python-sandbox {
  background: #e8e8ed;
  border-color: rgba(0, 0, 0, 0.1);
  /* Как светлый фон редактора (eclipse / белый холст CM) */
  --sandbox-shell-bg: #ffffff;
  --sandbox-shell-fg: #1a1a1a;
  --sandbox-shell-gutter-border: rgba(0, 0, 0, 0.1);
  --sandbox-shell-prompt-color: #b45309;
}

[data-theme="light"] .python-sandbox__splitter {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__splitter:hover {
  background: rgba(5, 184, 125, 0.18);
}

[data-theme="light"] .python-sandbox__header {
  background: rgba(0, 0, 0, 0.06);
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror-gutters {
  background: rgba(0, 0, 0, 0.05);
  border-right-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror-cursor {
  border-left-color: var(--white);
}

[data-theme="light"] .python-sandbox__lines {
  background: rgba(0, 0, 0, 0.05);
  border-right-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__toolbar {
  background: var(--sandbox-shell-bg);
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .python-sandbox__action {
  border-color: rgba(0, 0, 0, 0.2);
}

[data-theme="light"] .python-sandbox__action:hover {
  border-color: rgba(0, 0, 0, 0.4);
}

/* Светлая тема: зелёная подсветка */
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror .python-sandbox__error-line {
  background: rgba(239, 68, 68, 0.15) !important;
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-keyword,
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-string-2,
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-meta,
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-builtin {
  color: #05b87d !important;
}

/* Светлая тема: сильнее отличить от зелёного #05b87d и от чёрного текста */
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-variable,
[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-variable-3 {
  color: #1d4ed8 !important;
  font-weight: 500;
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-variable-2 {
  color: #2563eb !important;
  font-weight: 500;
}

[data-theme="light"] .python-sandbox__editor-wrap .CodeMirror span.cm-def {
  color: #a16207 !important;
  font-weight: 600;
  font-style: normal;
}

[data-theme="light"] .python-sandbox__shell {
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .python-sandbox__shell-scroll {
  scrollbar-color: rgba(0, 0, 0, 0.28) var(--sandbox-shell-bg);
}

[data-theme="light"] .python-sandbox__shell-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
  border-color: var(--sandbox-shell-bg);
}

[data-theme="light"] .python-sandbox__shell-banner {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .python-sandbox__output {
  border-top-color: rgba(0, 0, 0, 0.08);
  scrollbar-color: rgba(0, 0, 0, 0.28) var(--sandbox-shell-bg);
}

[data-theme="light"] .python-sandbox__output::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.22);
  border-color: var(--sandbox-shell-bg);
}

[data-theme="light"] .python-sandbox__output--transcript {
  border-top: none;
}

[data-theme="light"] .python-sandbox__data-tab {
  color: rgba(0, 0, 0, 0.6);
  border-color: rgba(0, 0, 0, 0.15);
}

[data-theme="light"] .python-sandbox__data-tab:hover {
  color: inherit;
  border-color: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .python-sandbox__data-tab--active {
  color: #05b87d;
  background: rgba(5, 184, 125, 0.12);
  border-color: rgba(5, 184, 125, 0.35);
}

[data-theme="light"] .python-sandbox__txt {
  background: rgba(0, 0, 0, 0.06);
  color: inherit;
}

[data-theme="light"] .python-sandbox__ods-wrap {
  background: rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .python-sandbox__ods-table th,
[data-theme="light"] .python-sandbox__ods-table td {
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .python-sandbox__ods-table th {
  background: rgba(0, 0, 0, 0.04);
  color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .python-sandbox__copy-btn {
  border-color: rgba(0, 0, 0, 0.15);
  color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .python-sandbox__copy-btn:hover {
  color: inherit;
  border-color: rgba(0, 0, 0, 0.25);
}

.python-sandbox__hang-notice {
  position: absolute;
  left: 0.75rem;
  right: 0.75rem;
  bottom: 0.75rem;
  z-index: 50;
  max-width: 36rem;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(251, 191, 36, 0.55);
  background: rgba(30, 27, 22, 0.94);
  color: #fef3c7;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.python-sandbox__hang-notice[hidden] {
  display: none !important;
}

.python-sandbox__hang-notice__title {
  margin: 0 0 0.35rem;
  font-weight: 600;
}

.python-sandbox__hang-notice__text {
  margin: 0;
}

[data-theme="light"] .python-sandbox__hang-notice {
  background: rgba(255, 251, 235, 0.98);
  color: #78350f;
  border-color: rgba(217, 119, 6, 0.45);
}

