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

.webr-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;
}

.webr-status-badge.ready {
  background-color: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}

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

[data-theme="dark"] .webr-status-badge.ready,
body.dark .webr-status-badge.ready {
  background-color: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  border-color: rgba(37, 99, 235, 0.35);
}

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

.webr-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"] .webr-island,
body.dark .webr-island {
  background-color: #111827;
  color: #f3f4f6;
  border-color: #374151;
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.45);
}

.webr-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"] .webr-island-header,
body.dark .webr-island-header {
  background-color: #1f2937;
  border-color: #374151;
}

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

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

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

.webr-run-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background-color: #2563eb !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(37, 99, 235, 0.25);
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.webr-run-btn:hover {
  background-color: #1d4ed8 !important;
  transform: translateY(-1px);
}

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

.webr-island-body {
  display: flex;
  flex-direction: column;
}

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

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

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

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

.webr-gutter {
  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"] .webr-gutter,
body.dark .webr-gutter {
  background-color: #161b22;
  border-right-color: #30363d;
  color: #6e7681;
}

.webrsource 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: 2;
  white-space: pre;
  overflow-x: auto;
}

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

.webrsource textarea::placeholder {
  color: #94a3b8;
}

.webrterm {
  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"] .webrterm,
body.dark .webrterm {
  background-color: #030712;
}

.webrterm 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"] .webrterm pre,
body.dark .webrterm pre {
  color: #9ca3af;
}

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

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



.sandbox-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease-out;
}

.sandbox-modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.sandbox-modal {
  width: 90%;
  max-width: 420px;
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.15);
  padding: 18px 20px;
  box-sizing: border-box;
  transform: translateY(-8px);
  transition: transform 0.15s ease-out;
}

.sandbox-modal-backdrop.active .sandbox-modal {
  transform: translateY(0);
}

[data-theme="dark"] .sandbox-modal,
body.dark .sandbox-modal {
  background-color: #111827;
  border-color: #374151;
  box-shadow: 0 16px 36px -4px rgba(0, 0, 0, 0.6);
}

.sandbox-modal-title {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #475569;
  margin-bottom: 8px;
}

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

.sandbox-modal-prompt {
  font-size: 0.92rem;
  font-weight: 500;
  color: #0f172a;
  margin-bottom: 12px;
  word-break: break-word;
}

[data-theme="dark"] .sandbox-modal-prompt,
body.dark .sandbox-modal-prompt {
  color: #f3f4f6;
}

.sandbox-modal-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background-color: #f8fafc;
  color: #0f172a;
  font-family: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
  outline: none;
  margin-bottom: 16px;
  transition: border-color 0.15s ease;
}

.sandbox-modal-input:focus {
  border-color: #2563eb;
}

[data-theme="dark"] .sandbox-modal-input,
body.dark .sandbox-modal-input {
  background-color: #030712;
  border-color: #374151;
  color: #e6edf3;
}

[data-theme="dark"] .sandbox-modal-input:focus {
  border-color: #38bdf8;
}

.sandbox-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.sandbox-modal-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s ease;
}

.sandbox-modal-btn.cancel {
  background: transparent;
  color: #64748b;
}

[data-theme="dark"] .sandbox-modal-btn.cancel {
  color: #94a3b8;
}

.sandbox-modal-btn.submit {
  background-color: #10b981;
  color: #ffffff;
}

.sandbox-modal-btn.submit.r-btn {
  background-color: #2563eb;
}

.sandbox-modal-btn:hover {
  opacity: 0.85;
}