.rcb {
  --rcb-accent: var(--interactive-accent, #3574f0);
  --rcb-bg: var(--background-primary, #ffffff);
  --rcb-bg-muted: var(--background-secondary, #f6f7f8);
  --rcb-border: var(--divider-color, var(--background-modifier-border, #d9dce1));
  --rcb-error: var(--text-error, #c9372c);
  --rcb-success: var(--text-success, var(--color-green, var(--text-normal, #176b35)));
  --rcb-text: var(--text-normal, #1f2328);
  --rcb-text-muted: var(--text-muted, #626a73);
  --rcb-toolbar: var(--background-secondary-alt, #f0f1f3);
  --rcb-font-interface: var(--font-interface, Inter, ui-sans-serif, sans-serif);
  --rcb-font-mono: var(--font-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace);
  --rcb-font-small: var(--font-ui-smaller, 11px);
  --rcb-radius: var(--radius-s, 6px);
  --rcb-control-height: var(--input-height, 30px);
  --rcb-focus-width: var(--focus-ring-width, 2px);
}

.rcb {
  background: var(--rcb-bg);
  border: 1px solid var(--rcb-border);
  border-radius: var(--rcb-radius);
  color: var(--rcb-text);
  font-family: var(--rcb-font-interface);
  margin: 1rem 0;
  overflow: hidden;
}

.rcb .rcb__button--secondary[hidden],
.rcb .rcb__console[hidden],
.rcb .rcb__notice[hidden],
.rcb .rcb__output[hidden],
.rcb .rcb__preview[hidden],
.rcb .rcb__button-icon[hidden] {
  display: none;
}

.rcb__sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.rcb__toolbar,
.rcb__console-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.rcb__toolbar {
  background: var(--rcb-toolbar);
  border-bottom: 1px solid var(--rcb-border);
  min-height: calc(var(--rcb-control-height) + 4px);
  padding: 0 6px 0 10px;
}

.rcb__identity,
.rcb__actions {
  align-items: center;
  display: flex;
  gap: 7px;
}

.rcb__file-icon {
  align-items: center;
  color: var(--rcb-accent);
  display: inline-flex;
  height: 16px;
  justify-content: center;
  width: 16px;
}

.rcb__icon {
  fill: none;
  height: 15px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
  width: 15px;
}

.rcb__language {
  font-size: var(--rcb-font-small);
  font-weight: var(--font-semibold, 600);
  text-transform: capitalize;
}

.rcb__environment {
  align-items: center;
  color: var(--rcb-text-muted);
  display: inline-flex;
  font-size: 9.5px;
  gap: 4px;
  text-transform: uppercase;
}

.rcb__environment-dot {
  background: currentColor;
  border-radius: 50%;
  height: 4px;
  opacity: 0.55;
  width: 4px;
}

.rcb__button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: var(--rcb-radius);
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-size: var(--rcb-font-small);
  font-weight: var(--font-medium, 500);
  justify-content: center;
  gap: 4px;
  min-height: calc(var(--rcb-control-height) - 4px);
  padding: 0 8px;
}

.rcb__button:focus-visible {
  outline: var(--rcb-focus-width) solid var(--rcb-accent);
  outline-offset: 1px;
  box-shadow: none;
}

.rcb__button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.rcb[data-state="running"] .rcb__button--run:disabled {
  cursor: progress;
  opacity: 0.9;
}

.rcb__button--run {
  background: var(--rcb-accent);
  color: var(--text-on-accent, #ffffff);
  min-width: calc(var(--rcb-control-height) - 4px);
  padding: 0;
  width: calc(var(--rcb-control-height) - 4px);
}

.rcb__button--run:hover:not(:disabled) {
  background: var(--interactive-accent-hover, var(--rcb-accent));
}

.rcb__button-icon {
  fill: currentColor;
  height: 13px;
  width: 13px;
}

.rcb__button-icon--running {
  animation: rcb-spin 0.8s linear infinite;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.rcb__button--secondary {
  background: transparent;
  border-color: var(--rcb-border);
  color: var(--rcb-text-muted);
}

.rcb__button--secondary:hover:not(:disabled) {
  background: var(--background-modifier-hover, rgb(127 127 127 / 12%));
  color: var(--rcb-text);
}

.rcb__editor {
  background: var(--rcb-bg);
}

.rcb__editor .cm-editor {
  background: transparent;
}

.rcb__editor .cm-editor.cm-focused,
.rcb__editor .cm-editor.cm-focused > .cm-scroller {
  outline: none;
}

.rcb__editor:focus-within {
  box-shadow: inset 0 0 0 var(--rcb-focus-width) var(--background-modifier-border-focus, var(--rcb-accent));
}

.rcb__editor .cm-scroller,
.rcb__editor .cm-content,
.rcb__editor .cm-gutters {
  font-family: var(--rcb-font-mono);
  font-size: 13px;
  line-height: 1.55;
}

.rcb__editor .cm-scroller {
  /* 100 source lines + the two numbered editing lines, including 16px content padding. */
  max-height: var(--rcb-editor-max-height, calc(102lh + 16px));
  overflow: auto;
}

.rcb__editor .cm-content {
  padding: 7px 0 9px;
}

.rcb__editor .cm-gutters {
  background: transparent;
  border-right: 0;
  color: var(--rcb-text-muted);
  padding-left: 4px;
}

.rcb__editor .cm-activeLine,
.rcb__editor .cm-activeLineGutter {
  background: color-mix(in srgb, var(--rcb-accent) 9%, transparent);
}

.rcb__editor .cm-cursor {
  border-left-color: var(--rcb-text);
}

.rcb__editor .cm-selectionBackground {
  background: color-mix(in srgb, var(--rcb-accent) 24%, transparent);
}

.rcb__console {
  background: var(--rcb-bg);
  border-top: 1px solid var(--rcb-border);
}

.rcb__console-header {
  background: var(--rcb-toolbar);
  border-bottom: 1px solid var(--rcb-border);
  min-height: 24px;
  padding: 0 10px;
}

.rcb__console-title {
  color: var(--rcb-text);
  font-size: 10.5px;
  font-weight: var(--font-semibold, 600);
  letter-spacing: 0;
}

.rcb__console-meta {
  color: var(--rcb-text-muted);
  font-size: 9.5px;
  max-width: min(65%, 440px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@keyframes rcb-spin {
  to {
    transform: rotate(360deg);
  }
}

.markdown-rendered .rcb pre.rcb__output,
.rcb pre.rcb__output {
  background: var(--rcb-bg);
  border: 0;
  border-radius: 0;
  box-shadow: none;
  color: var(--rcb-text);
  font-family: var(--rcb-font-mono);
  font-size: 12px;
  line-height: 1.55;
  margin: 0;
  max-height: none;
  min-height: 0;
  overflow: visible;
  padding: 9px 12px 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

.rcb__preview {
  background: #ffffff;
  border-top: 1px solid var(--rcb-border);
}

.rcb__preview-frame {
  background: #ffffff;
  border: 0;
  display: block;
  height: 120px;
  width: 100%;
}

.rcb__preview-frame[data-scripts="isolated"] {
  height: 120px;
}

.rcb__dart-execution-frame {
  border: 0;
  height: 0;
  left: -10000px;
  position: fixed;
  top: -10000px;
  width: 0;
}

.rcb__notice {
  background: color-mix(in srgb, var(--rcb-error) 8%, transparent);
  border-top: 1px solid color-mix(in srgb, var(--rcb-error) 22%, var(--rcb-border));
  color: var(--rcb-text-muted);
  font-size: var(--rcb-font-small);
  line-height: 1.45;
  padding: 8px 12px;
}

.rcb[data-state="running"] .rcb__console-meta,
.rcb[data-state="running"] .rcb__output {
  color: var(--rcb-accent);
}

.rcb[data-state="success"] .rcb__console-meta {
  color: var(--rcb-success);
}

.rcb[data-state="error"] .rcb__console-meta,
.rcb[data-state="error"] .rcb__output,
.rcb[data-state="unavailable"] .rcb__notice {
  color: var(--rcb-error);
}

@media (prefers-reduced-motion: reduce) {
  .rcb__button-icon--running {
    animation: none;
  }
}
