/* RL Lab · Python reward studio: toolbar, editor shell, console, reference */

#view-rl-lab .rl-code-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

#view-rl-lab .rl-toolbar-spacer {
  flex: 1;
}

#view-rl-lab .rl-code-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.36fr);
  gap: 0;
  min-height: 34rem;
}

#view-rl-lab .rl-code-editor-shell {
  display: grid;
  grid-template-rows: minmax(26rem, 1fr) auto auto;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 0.8rem 0 0 0.8rem;
  background: #10131a;
}

#view-rl-lab .rl-code-editor,
#view-rl-lab .rl-code-fallback {
  width: 100%;
  height: 100%;
  min-height: 26rem;
  border: 0;
  background: #10131a;
  color: #e6edf3;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.8rem;
  line-height: 1.58;
  resize: vertical;
}

#view-rl-lab .rl-code-fallback {
  padding: 1rem;
  tab-size: 4;
}

#view-rl-lab .rl-code-console {
  display: flex;
  min-height: 2.4rem;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.8rem;
  border-top: 1px solid #2b3342;
  background: #0b0e14;
  color: #c9d4e0;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.72rem;
}

#view-rl-lab .rl-code-console::before {
  content: "›";
  color: #4b5b70;
  font-weight: 700;
}

#view-rl-lab .rl-code-console.is-valid,
#view-rl-lab .rl-code-console.is-success {
  color: #86efac;
}

#view-rl-lab .rl-code-console.is-error {
  color: #fca5a5;
}

#view-rl-lab .rl-code-console.is-busy {
  color: #fcd34d;
}

#view-rl-lab .rl-code-console .rl-code-status {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#view-rl-lab .rl-code-console button {
  flex: 0 0 auto;
  padding: 0.15rem 0.5rem;
  border: 1px solid #2b3342;
  border-radius: 0.3rem;
  background: #171b24;
  color: inherit;
  font: inherit;
}

#view-rl-lab .rl-code-statusbar {
  display: flex;
  min-height: 2rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.7rem;
  border-top: 1px solid #2b3342;
  background: #171b24;
  color: #9aa8ba;
  font-size: 0.68rem;
}

#view-rl-lab kbd {
  padding: 0.05rem 0.26rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.25rem;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--text) 22%, transparent);
  color: inherit;
  font: inherit;
}

#view-rl-lab .rl-code-statusbar kbd {
  border-color: #3a4458;
  background: #10131a;
  box-shadow: none;
}

#view-rl-lab .rl-code-reference {
  display: flex;
  min-height: 0;
  max-height: 40rem;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-left: 0;
  border-radius: 0 0.8rem 0.8rem 0;
  background: color-mix(in srgb, var(--surface-soft) 88%, transparent);
}

#view-rl-lab .rl-reference-heading {
  padding: 1rem 1rem 0.6rem;
}

#view-rl-lab .rl-reference-heading h3 {
  margin: 0.15rem 0 0.35rem;
  font-size: 0.95rem;
}

#view-rl-lab .rl-reference-heading p,
#view-rl-lab .rl-code-reference p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

#view-rl-lab .rl-reference-tabs {
  display: flex;
  gap: 0.15rem;
  padding: 0 0.6rem;
  border-bottom: 1px solid var(--border);
}

#view-rl-lab .rl-reference-tab {
  padding: 0.5rem 0.55rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 650;
}

#view-rl-lab .rl-reference-tab.is-active {
  border-bottom-color: var(--primary);
  color: var(--text);
}

#view-rl-lab .rl-reference-panel {
  display: block;
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding: 0.8rem 0.9rem 1rem;
}

#view-rl-lab .rl-reference-panel > * + * {
  margin-top: 0.6rem;
}

#view-rl-lab .rl-reference-panel h4 {
  margin: 0.2rem 0 0;
  color: var(--text-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#view-rl-lab .rl-code-contract {
  margin: 0;
  padding: 0.65rem;
  overflow: auto;
  border: 1px solid #2b3342;
  border-radius: 0.45rem;
  background: #10131a;
  color: #d8e1ec;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 0.66rem;
  line-height: 1.45;
}

#view-rl-lab .rl-reference-fields {
  display: grid;
  gap: 0.35rem;
  margin: 0;
}

#view-rl-lab .rl-reference-fields div {
  display: grid;
  gap: 0.15rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--surface);
}

#view-rl-lab .rl-reference-fields dt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.68rem;
}

#view-rl-lab .rl-reference-fields dt span {
  color: var(--muted-light);
  font-family: "SFMono-Regular", Consolas, monospace;
}

#view-rl-lab .rl-reference-fields dd {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.45;
}

#view-rl-lab .rl-field-chip {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary);
  font-weight: 700;
}

#view-rl-lab .rl-reference-search {
  width: 100%;
}

#view-rl-lab .rl-helper-list {
  display: grid;
  gap: 0.35rem;
}

#view-rl-lab .rl-helper {
  display: grid;
  gap: 0.15rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface);
  text-align: left;
}

#view-rl-lab .rl-helper:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

#view-rl-lab .rl-helper code {
  color: var(--primary);
  font-size: 0.68rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

#view-rl-lab .rl-helper span {
  color: var(--text-soft);
  font-size: 0.68rem;
  line-height: 1.45;
}

#view-rl-lab .rl-helper small {
  color: var(--muted-light);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.62rem;
  overflow-wrap: anywhere;
}

#view-rl-lab .rl-helper[data-rl-helper-category="builtin"] code {
  color: var(--text-soft);
}

#view-rl-lab .rl-reference-note {
  font-size: 0.66rem;
}

#view-rl-lab .rl-reference-note code {
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--surface);
  font-size: 0.62rem;
}

#view-rl-lab .rl-snippet-list {
  display: grid;
  gap: 0.55rem;
}

#view-rl-lab .rl-snippet {
  display: grid;
  gap: 0.35rem;
  padding: 0.55rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface);
}

#view-rl-lab .rl-snippet header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.72rem;
}

#view-rl-lab .rl-reference-rules {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--text-soft);
  font-size: 0.7rem;
  line-height: 1.5;
}

#view-rl-lab .rl-reference-rules li + li {
  margin-top: 0.25rem;
}

#view-rl-lab .rl-code-hash {
  font-size: clamp(0.8rem, 1.6vw, 1.2rem);
  overflow-wrap: anywhere;
}

/* Ace autocomplete popup rendered against the dark editor theme */

.ace_editor.ace_autocomplete {
  width: 380px;
  border: 1px solid #2b3342;
  border-radius: 0.45rem;
  background: #171b24;
  color: #e6edf3;
  font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  box-shadow: 0 16px 40px rgb(0 0 0 / 40%);
}

.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {
  background: #243047;
}

.ace_editor.ace_autocomplete .ace_completion-highlight {
  color: #93c5fd;
}

.ace_editor.ace_autocomplete .ace_completion-meta {
  color: #7d8aa0;
  opacity: 1;
}

.ace_tooltip.ace_doc-tooltip {
  max-width: 420px;
  padding: 10px 12px;
  border: 1px solid #2b3342;
  border-radius: 0.45rem;
  background: #171b24;
  color: #e6edf3;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  white-space: normal;
}

/* Keep these after the base rules: this sheet loads last, so the stacked
   layout must be declared here to win over the two-column default. */
@media (max-width: 1050px) {
  #view-rl-lab .rl-code-workbench {
    grid-template-columns: 1fr;
  }

  #view-rl-lab .rl-code-editor-shell {
    border-radius: 0.8rem 0.8rem 0 0;
  }

  #view-rl-lab .rl-code-reference {
    max-height: 26rem;
    border-left: 1px solid var(--border-strong);
    border-top: 0;
    border-radius: 0 0 0.8rem 0.8rem;
  }
}

@media (max-width: 720px) {
  #view-rl-lab .rl-code-statusbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.25rem;
  }

  #view-rl-lab .rl-code-editor-shell {
    grid-template-rows: minmax(22rem, 1fr) auto auto;
  }

  #view-rl-lab .rl-code-editor,
  #view-rl-lab .rl-code-fallback {
    min-height: 22rem;
  }
}
