/**
 * The modelling workbench panel.
 *
 * ⚠️ A WITHHELD STATUS MUST BE LEGIBLE WITHOUT COLOUR, AND IT MUST NOT LOOK
 * LIKE AN ERROR. "Economics: not-modelled" is the engine being honest, not
 * something going wrong — red would teach a reader to expect it to be fixed,
 * and a faint grey would teach them to skip it. So the status word itself is
 * always printed as text, in a chip, and the styling only reinforces what the
 * word already says.
 *
 * ⚠️ NO EPISTEMIC DISTINCTION LIVES IN COMPOSITING. Withheld is marked by a
 * dashed rule and its own hue, never by opacity alone: an alpha difference
 * disappears against a different backdrop and cannot be read by anyone who
 * cannot compare two shades side by side.
 */

.workbench-surfaces,
[data-workbench-answer],
[data-workbench-weather],
[data-workbench-weather-outcome] {
  /* Follow the surrounding Control palette. The old fixed dark palette made
     opening saved work look like another application, even in light mode. */
  --wb-canvas: var(--surface);
  --wb-surface: var(--surface-soft);
  --wb-ink: var(--ink);
  --wb-muted: var(--muted);
  --wb-line: var(--line);
  --wb-stated: var(--action);
  --wb-withheld: var(--withheld-ink);
}

.workbench-surfaces {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.workbench-surfaces *,
.workbench-surfaces *::before,
.workbench-surfaces *::after { box-sizing: border-box; }

.workbench-surface {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--wb-line);
  border-radius: 14px;
  color: var(--wb-ink);
  background: var(--wb-canvas);
}

.workbench-surface h3 {
  margin: 0 0 6px;
  color: var(--wb-ink);
  font-size: 1.05rem;
}

.workbench-surface p { margin: 8px 0; }
.workbench-binding,
.workbench-protocol { color: var(--wb-muted); font-size: .82rem; }
.workbench-protocol code { color: var(--wb-muted); }

.workbench-required {
  padding: 8px 10px;
  border-left: 4px solid var(--wb-stated);
  background: var(--wb-surface);
  font-size: .9rem;
}

.workbench-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0;
  padding: 0;
  list-style: none;
}
.workbench-actions li {
  padding: 4px 10px;
  border: 1px solid var(--wb-line);
  border-radius: 999px;
  background: var(--wb-surface);
  font-size: .86rem;
}

.workbench-policies code {
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--wb-surface);
  font-size: .85rem;
}

/* The cohort. ⚠️ Deliberately NOT striped or numbered — a row index is an
   order, and the engine has said there is no order. */
.workbench-cohort {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
  font-size: .88rem;
}
.workbench-cohort caption {
  margin-bottom: 6px;
  color: var(--wb-withheld);
  font-weight: 700;
  text-align: left;
}
.workbench-cohort th,
.workbench-cohort td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--wb-line);
  text-align: left;
}
.workbench-cohort th { color: var(--wb-muted); font-weight: 600; }

.workbench-statuses {
  display: grid;
  gap: 6px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}
.workbench-status {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 6px 10px;
  border-left: 4px solid var(--wb-stated);
  background: var(--wb-surface);
  font-size: .87rem;
}
/* Dashed, and its own hue — two signals, neither of them opacity. */
.workbench-status-withheld {
  border-left-style: dashed;
  border-left-color: var(--wb-withheld);
}
.workbench-status b { color: var(--wb-ink); }
.workbench-status-value {
  padding: 1px 7px;
  border-radius: 4px;
  border: 1px solid var(--wb-line);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem;
}
.workbench-status-withheld .workbench-status-value { color: var(--wb-withheld); }
.workbench-status-reason { color: var(--wb-muted); }

.workbench-refusals { margin-top: 10px; font-size: .87rem; }
.workbench-refusals summary { color: var(--wb-muted); cursor: pointer; }
.workbench-refusals ul { margin: 8px 0; padding-left: 20px; }
.workbench-refusals li { margin: 3px 0; }
.workbench-next { color: var(--wb-muted); }

@media (max-width: 640px) {
  .workbench-cohort { display: block; overflow-x: auto; }
}

/* ---------------------------------------------------------------------------
 * The four states of a published action.
 *
 * ⚠️ EACH STATE IS DISTINGUISHED BY SHAPE AND BY A PRINTED WORD, NOT BY ALPHA.
 * A greyed-out chip says "this is off" without saying why, and the why is the
 * whole content here: `deferred` is a capability Control has not reached yet,
 * `unbound` is one Control has never heard of, and those have different people
 * fixing them. So the state is written in words next to the label, and the
 * styling only reinforces the word.
 *
 * ⚠️ `callable` is the ONLY one that is a button, and it is the only one that
 * looks like one. A chip that invites a press and then refuses is worse than a
 * chip that never invited it.
 * ------------------------------------------------------------------------- */

.workbench-action { display: flex; align-items: baseline; gap: 8px; }

.workbench-action-callable { padding: 0; border: 0; background: none; }
.workbench-action-callable .workbench-run {
  padding: 5px 12px;
  border: 1px solid var(--wb-stated);
  border-radius: 999px;
  color: var(--wb-canvas);
  background: var(--wb-stated);
  font: inherit;
  font-size: .86rem;
  cursor: pointer;
}
.workbench-action-callable .workbench-run:hover { filter: brightness(1.12); }
.workbench-action-callable .workbench-run:disabled { cursor: progress; }

/* Not-callable states: a dashed rule, so the difference survives greyscale. */
.workbench-action-elsewhere,
.workbench-action-deferred,
.workbench-action-unbound {
  border-style: dashed;
  color: var(--wb-muted);
}
.workbench-action-elsewhere { border-color: var(--wb-stated); }
.workbench-action-deferred { border-color: var(--wb-withheld); }
.workbench-action-unbound { border-color: var(--wb-muted); }

.workbench-action-state {
  color: var(--wb-withheld);
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.workbench-action-elsewhere .workbench-action-state { color: var(--wb-stated); }
.workbench-action-reason {
  flex-basis: 100%;
  color: var(--wb-muted);
  font-size: .78rem;
}

/* ---------------------------------------------------------------------------
 * What came back.
 * ------------------------------------------------------------------------- */

.workbench-answer {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--wb-line);
  border-radius: 12px;
  color: var(--wb-ink);
  background: var(--wb-surface);
}
.workbench-answer-head { display: flex; gap: 10px; margin: 0 0 8px; }
.workbench-answer[data-answer-status="failed"] { border-color: var(--wb-withheld); }

.workbench-rows { width: 100%; margin: 8px 0 0; border-collapse: collapse; }
.workbench-rows th, .workbench-rows td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--wb-line);
  text-align: left;
  font-size: .86rem;
}
.workbench-open {
  padding: 3px 10px;
  border: 1px solid var(--wb-stated);
  border-radius: 999px;
  color: var(--wb-stated);
  background: none;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}

.workbench-refusal {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-left: 3px solid var(--wb-withheld);
  color: var(--wb-ink);
}
.workbench-raw pre {
  max-height: 320px;
  overflow: auto;
  padding: 8px;
  border-radius: 8px;
  background: var(--wb-canvas);
  font-size: .78rem;
}

/* ---------------------------------------------------------------------------
 * The step that comes next, and the weather it asks for.
 *
 * ⚠️ Colour is never the only carrier here. The next step is stated in the
 * suite's own words, a withheld pin is stated in a sentence, and a refusal
 * carries its code as text — the rules below add emphasis to writing that
 * already says everything, rather than replacing it.
 * ------------------------------------------------------------------------- */

.workbench-next {
  margin: 0 0 10px;
  padding: 8px 10px;
  border-left: 3px solid var(--wb-stated);
  color: var(--wb-ink);
  background: var(--wb-canvas);
  border-radius: 0 8px 8px 0;
}
.workbench-next-lead { color: var(--wb-ink); font-size: .86rem; }

.workbench-weather {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--wb-line);
  border-radius: 12px;
  color: var(--wb-ink);
  background: var(--wb-surface);
}
.workbench-weather h3 { margin: 0 0 4px; font-size: .95rem; }
.workbench-weather-note {
  margin: 0;
  color: var(--wb-ink);
  font-size: .82rem;
}
.workbench-weather-source {
  display: block;
  margin-top: .2rem;
}
.workbench-weather-check {
  padding: 3px 10px;
  border: 1px solid var(--wb-stated);
  border-radius: 999px;
  color: var(--wb-stated);
  background: none;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
}
.workbench-weather-check:disabled { cursor: progress; }

.workbench-select-row[data-weather-check] { cursor: pointer; }
.workbench-select-row[data-weather-check]:hover,
.workbench-select-row[data-weather-check]:focus {
  background: var(--wb-canvas);
}
.workbench-select-row-selected[aria-selected="true"] {
  background: var(--wb-canvas);
}
.workbench-select-row-selected[aria-selected="true"] td {
  background: var(--wb-canvas);
}
.workbench-select-row-selected[aria-selected="true"] td:first-child {
  box-shadow: inset 3px 0 var(--wb-stated);
}
.workbench-select-row-selected[aria-selected="true"] .workbench-weather-check {
  color: var(--wb-canvas);
  background: var(--wb-stated);
}
[data-weather-outcome]:focus {
  outline: 2px solid var(--wb-stated);
  outline-offset: 2px;
}
