.code-sandbox-wrapper,
.py-sandbox-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  margin: 1.5rem 0;
  width: 100%;
}

.py-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background-color: #fef2f2;
  color: #ef4444;
  border: 1px solid #fecaca;
  margin-bottom: 8px;
}

.py-status-badge.ready {
  background-color: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

[data-theme="dark"] .py-status-badge,
body.dark .py-status-badge {
  background-color: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .py-status-badge.ready,
body.dark .py-status-badge.ready {
  background-color: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.3);
}

.py-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.code-island,
.py-island {
  display: flex;
  flex-direction: column;
  width: 100%;
  background-color: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  margin: 0;
  overflow: hidden;
  box-shadow: 0 4px 18px -2px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

[data-theme="dark"] .code-island,
[data-theme="dark"] .py-island,
body.dark .code-island,
body.dark .py-island {
  background-color: #111827;
  color: #f3f4f6;
  border-color: #374151;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
}

.code-island-header,
.py-island-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="dark"] .code-island-header,
[data-theme="dark"] .py-island-header,
body.dark .code-island-header,
body.dark .py-island-header {
  background-color: #1f2937;
  border-color: #374151;
}

.code-header-left,
.py-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.code-island-title,
.py-island-title {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #475569;
}

[data-theme="dark"] .code-island-title,
[data-theme="dark"] .py-island-title,
body.dark .code-island-title,
body.dark .py-island-title {
  color: #9ca3af;
}

.code-run-btn,
.py-run-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: #10b981 !important;
  color: #ffffff !important;
  border: none !important;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.2);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.code-run-btn:hover,
.py-run-btn:hover {
  background-color: #059669 !important;
  transform: translateY(-1px);
}

.code-run-btn:disabled,
.py-run-btn:disabled {
  background-color: #94a3b8 !important;
  cursor: not-allowed;
  transform: none;
  opacity: 0.7;
}

.code-island-body,
.py-island-body {
  display: flex;
  flex-direction: column;
}

@media (min-width: 768px) {
  .code-island-body,
  .py-island-body {
    flex-direction: row;
  }
}

.code-source,
.pysource {
  flex: 1;
  min-width: 0;
  display: flex;
  position: relative;
  background-color: #fcfcfd;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="dark"] .code-source,
[data-theme="dark"] .pysource,
body.dark .code-source,
body.dark .pysource {
  background-color: #0d1117;
  border-color: #374151;
}

@media (min-width: 768px) {
  .code-source,
  .pysource {
    border-bottom: none;
    border-right: 1px solid #e2e8f0;
  }
  [data-theme="dark"] .code-source,
  [data-theme="dark"] .pysource,
  body.dark .code-source,
  body.dark .pysource {
    border-right-color: #374151;
  }
}

.code-gutter,
.py-line-numbers {
  width: 42px;
  flex-shrink: 0;
  padding: 12px 8px 12px 0;
  text-align: right;
  background-color: #f1f5f9;
  border-right: 1px solid #e2e8f0;
  color: #94a3b8;
  font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  user-select: none;
  box-sizing: border-box;
  overflow: hidden;
  white-space: pre;
}

[data-theme="dark"] .code-gutter,
[data-theme="dark"] .py-line-numbers,
body.dark .code-gutter,
body.dark .py-line-numbers {
  background-color: #161b22;
  border-right-color: #30363d;
  color: #6e7681;
}

.code-source textarea,
.pysource textarea {
  flex: 1;
  min-width: 0;
  min-height: 160px;
  padding: 12px 14px;
  border: none;
  background: transparent;
  color: #0f172a;
  font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  box-sizing: border-box;
  tab-size: 4;
  white-space: pre;
  overflow-x: auto;
}

[data-theme="dark"] .code-source textarea,
[data-theme="dark"] .pysource textarea,
body.dark .code-source textarea,
body.dark .pysource textarea {
  color: #e6edf3;
}

.code-source textarea::placeholder,
.pysource textarea::placeholder {
  color: #94a3b8;
}

.code-term,
.pyterm {
  flex: 1;
  min-width: 0;
  background-color: #f8fafc;
  padding: 12px 16px;
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
  box-sizing: border-box;
}

[data-theme="dark"] .code-term,
[data-theme="dark"] .pyterm,
body.dark .code-term,
body.dark .pyterm {
  background-color: #030712;
}

.code-term pre,
.pyterm pre {
  margin: 0;
  padding: 0;
  font-family: "JetBrains Mono", "Fira Code", Consolas, Monaco, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: #334155;
  background: transparent !important;
}

[data-theme="dark"] .code-term pre,
[data-theme="dark"] .pyterm pre,
body.dark .code-term pre,
body.dark .pyterm pre {
  color: #9ca3af;
}

.py-err {
  color: #dc2626 !important;
  font-weight: 500;
}

[data-theme="dark"] .py-err,
body.dark .py-err {
  color: #f87171 !important;
}