/* Cordis definition card: DisclosureRow chrome (leading/chevron/title come from
   that primitive) plus this card's own trailing run switch and source body.
   No running sweep: `cordis_define` only registers a definition in host memory,
   so the call settles in the same turn it starts and the state dot carries the
   whole signal. */

.card {
  display: flex;
  flex-direction: column;
}

/* The shared cordis accent (matches ui-tool's [data-tool^='cordis_'] rows). */
.card .title,
.card .chevron {
  color: var(--dsw-alias-state-business-primary);
}

.title {
  flex: none;
  font-size: 14px;
  font-weight: 500;
  line-height: 24px;
}

.row {
  gap: 0;
}

.separator {
  flex: none;
  width: 2px;
  height: 2px;
  border-radius: 1px;
  margin: 0 8px;
  background: var(--dsw-alias-state-business-primary);
}

.name {
  flex: none;
  max-width: 40%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 24px;
  color: var(--dsw-alias-label-secondary);
}

/* The purpose absorbs the remaining width and clips first: the name and the
   switch are the two parts that must survive a narrow row. */
.purpose {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  line-height: 24px;
  color: var(--dsw-alias-label-tertiary);
}

.errorSummary {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  line-height: 24px;
  color: var(--dsw-alias-state-error-primary);
}

.requestError {
  flex: none;
  max-width: 40%;
  overflow: hidden;
  margin-left: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 24px;
  color: var(--dsw-alias-state-error-primary);
}

.readout {
  display: inline-flex;
  flex: none;
  align-items: center;
  margin-left: 8px;
}

/* Said once in the expanded body: this card records, the panel operates. */
.panelHint {
  margin: 4px 0 2px 4px;
  font-size: 11px;
  line-height: 16px;
  color: var(--dsw-alias-label-caption);
}

.statusLabel {
  font-size: 12px;
  line-height: 24px;
  color: var(--dsw-alias-label-caption);
}

/* The model's question, shown beside the approve/decline pair. */
.approvalPrompt {
  flex: none;
  max-width: 40%;
  overflow: hidden;
  margin-left: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 24px;
  color: var(--dsw-alias-label-secondary);
}

/* A qualified success (nothing acknowledged the dispatch, or the browser half
   parked on missing services): informational, so it must not read as the error
   line beside it. */
.notice {
  flex: none;
  max-width: 40%;
  overflow: hidden;
  margin-left: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  line-height: 24px;
  color: var(--dsw-alias-label-caption);
}

.switch {
  height: 22px;
  padding: 0 8px;
  font-size: 12px;
}

/* Terminal definitions (unloaded, or lost to a host restart) stay in the flow
   as a greyed card: the define call is still in the session log, so removing
   the row would leave a replay hole. */
.card[data-terminal] .title,
.card[data-terminal] .name,
.card[data-terminal] .purpose,
.card[data-terminal] .statusLabel {
  color: var(--dsw-alias-label-caption);
}

.card[data-terminal] .separator {
  background: var(--dsw-alias-label-caption);
}

.bodyWrap {
  display: flex;
  flex-direction: column;
}

.sourceCard {
  display: flex;
  flex-direction: column;
  margin: 4px 0 4px 4px;
}

.sourceTabs {
  display: flex;
  height: 32px;
  border-bottom: 1px solid var(--dsw-alias-border-l2);
}

.sourceTab {
  position: relative;
  padding: 0 10px;
  border: 0;
  background: transparent;
  color: var(--dsw-alias-label-tertiary);
  cursor: pointer;
  font: var(--dsw-font-xs-13);
}

.sourceTab:hover:not(:disabled) {
  background: var(--dsw-alias-interactive-bg-hover);
  color: var(--dsw-alias-label-primary);
}

.sourceTab:disabled {
  cursor: default;
  opacity: 0.4;
}

.sourceTabActive {
  color: var(--dsw-alias-state-business-primary);
}

.sourceTabActive::after {
  position: absolute;
  right: 10px;
  bottom: 0;
  left: 10px;
  height: 2px;
  border-radius: 1px 1px 0 0;
  background: var(--dsw-alias-state-business-primary);
  content: '';
}

.sourceTab:focus-visible {
  outline: 1px solid var(--dsw-alias-state-business-primary);
  outline-offset: -1px;
}

.sourcePanel {
  max-height: 260px;
  overflow: auto;
}

.sourceCode {
  margin: 0;
}

.codeSection {
  display: flex;
  flex-direction: column;
  max-height: 260px;
  margin: 4px 0 4px 4px;
  overflow: auto;
}

.sectionLabel {
  flex: none;
  padding: 2px 0;
  font-size: 11px;
  font-weight: 500;
  line-height: 16px;
  color: var(--dsw-alias-label-caption);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.output {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--dsw-alias-border-l1);
  border-radius: 8px;
  background: var(--dsw-alias-markdown-code-block);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: var(--dsw-font-markdown-code-block-small);
  color: var(--dsw-alias-label-secondary);
}

.output[data-error] {
  color: var(--dsw-alias-state-error-primary);
}

.inspectButton {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 4px;
  margin: 4px 0 2px 4px;
  padding: 2px 8px;
  border: 1px solid var(--dsw-alias-border-l2);
  border-radius: 999px;
  background: var(--dsw-alias-bg-base);
  color: var(--dsw-alias-label-secondary);
  font-size: 11px;
  line-height: 16px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 100ms ease;
}

.card:hover .inspectButton,
.inspectButton:focus-visible {
  opacity: 1;
}

.inspectButton:hover {
  background: var(--dsw-alias-interactive-bg-hover-solid);
  color: var(--dsw-alias-label-primary);
}

.visuallyHidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .inspectButton {
    transition: none;
  }
}
