/* Orchestration editor: problems, wiring, results, estimate, notes and groups,
   search and version diff. Uses the tokens in styles.css only (DESIGN.md):
   neutral graphite surfaces, phosphor green for live/primary/focus, and the
   success / warning / danger roles for state. No blue or purple. */

/* The editor hides and shows its bars, banners and popovers with the
   [hidden] attribute, but most of them set their own display (flex/grid),
   which outranks the browser's [hidden] rule. Without this the version-diff
   bar, the wiring banner and the problems chip never went away. */
.living-graph-workspace [hidden],
[data-orch-pane] [hidden] { display: none !important; }

/* ── Problems ───────────────────────────────────────────────────────── */
.orch-problems-btn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); }
.orch-problems-btn.is-blocking { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.orch-problems {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 30; width: min(24rem, calc(100% - 1.2rem)); max-height: 60%;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card-strong-bg); border: 1px solid var(--stroke-strong); border-radius: 0.65rem;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.orch-problems > header { display: flex; align-items: center; gap: 0.4rem; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--stroke); font-size: 0.82rem; }
.orch-problems > header span { flex: 1; color: var(--text-faint); font-size: 0.74rem; }
.orch-problems-list { list-style: none; margin: 0; padding: 0.35rem; overflow-y: auto; }
.orch-problem-row {
  display: grid; gap: 0.15rem; width: 100%; text-align: left; padding: 0.5rem 0.6rem; border-radius: 0.5rem;
  border: 1px solid transparent; background: transparent; color: var(--text); cursor: pointer;
  border-left: 3px solid var(--warning);
}
.orch-problem-row.is-blocking { border-left-color: var(--danger); }
.orch-problem-row:hover, .orch-problem-row:focus-visible { background: var(--surface-highlight); border-color: var(--stroke-strong); }
.orch-problem-node { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text-soft); }
.orch-problem-text { font-size: 0.82rem; }
.living-graph-workspace .orch-node.has-problem { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 16%, transparent); }
.orch-problem-flag {
  position: absolute; top: -0.55rem; left: -0.55rem; z-index: 3; width: 1.25rem; height: 1.25rem; border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--danger); color: #161616; border: 2px solid var(--bg);
}
.is-problem-field { border-color: var(--danger) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent) !important; }

/* ── Wiring ─────────────────────────────────────────────────────────── */
.orch-wiring-banner {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.9rem; font-size: 0.82rem; color: var(--text-soft);
  background: var(--card-strong-bg); border-bottom: 1px solid var(--stroke);
}
.orch-wiring-banner > span { flex: 1; min-width: 0; }
.orch-wiring-banner strong { color: var(--text); }
.living-graph-workspace .orch-edge-implicit .orch-edge-path {
  stroke: color-mix(in srgb, var(--warning) 70%, transparent); stroke-width: 1.6; stroke-dasharray: 5 6;
}
.orch-wiring-fieldset { border: 1px solid var(--stroke); border-radius: 0.65rem; padding: 0.75rem 0.9rem; }
.orch-wiring-fieldset legend { padding: 0 0.3rem; }
.orch-wiring-option { display: flex; gap: 0.6rem; align-items: flex-start; font-size: 0.85rem; color: var(--text-soft); cursor: pointer; }
.orch-wiring-option input { margin-top: 0.25rem; accent-color: var(--accent); }
.orch-wiring-option strong { color: var(--text); margin-right: 0.25rem; }
.orch-parallel-input { max-width: 7rem; }

/* ── Card quick actions and pinned sample data ──────────────────────── */
.orch-node-quick-group {
  position: absolute; right: 0.5rem; bottom: calc(100% + 0.3rem); z-index: 4; display: none; align-items: center; gap: 0.1rem; padding: 0.15rem;
  background: var(--card-strong-bg); border: 1px solid var(--stroke-strong); border-radius: 0.55rem; box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.orch-node:hover > .orch-node-quick-group, .orch-node.is-selected > .orch-node-quick-group, .orch-node:focus-within > .orch-node-quick-group { display: inline-flex; }
.orch-node-quick:hover { color: var(--accent); background: var(--surface-highlight); }
.orch-node-quick[aria-pressed="true"] { color: var(--warning); }
@media (hover: none) { .orch-node.is-selected > .orch-node-quick-group { display: inline-flex; } }
.living-graph-workspace .orch-node.is-pinned { border-style: dashed; border-color: color-mix(in srgb, var(--warning) 70%, transparent); }
.orch-pin-badge {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 1.25rem; height: 1.25rem; border-radius: 999px;
  cursor: help; color: var(--warning); background: color-mix(in srgb, var(--warning) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
}
/* The dashed outline says "sample data"; a corner tag spells it out. */
.living-graph-workspace .orch-node.is-pinned::after {
  content: "Sample output"; position: absolute; left: 0.75rem; bottom: -0.6rem; padding: 0 0.4rem; border-radius: 999px;
  font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; pointer-events: none;
  color: var(--warning); background: var(--bg); border: 1px dashed color-mix(in srgb, var(--warning) 60%, transparent);
}
.orch-visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ── Results of the shown run ───────────────────────────────────────── */
.orch-node-result {
  display: grid; gap: 0.35rem; min-width: 0; box-sizing: border-box; overflow: hidden; overflow-wrap: anywhere;
  margin: 0 0.6rem 0.6rem; padding: 0.45rem 0.55rem; border-radius: 0.5rem;
  background: var(--surface-strong); border: 1px solid var(--stroke); font-size: 0.75rem;
}
.orch-node-result.is-error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.orch-result-chips { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.orch-result-chip {
  padding: 0.05rem 0.4rem; border-radius: 999px; font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 0.68rem; color: var(--text-soft); background: var(--chip-bg); border: 1px solid var(--chip-border);
}
.orch-result-chip.is-warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.orch-result-chip.is-retrying { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, transparent); animation: orch-retry-pulse 1.4s ease-in-out infinite; }
@keyframes orch-retry-pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) { .orch-result-chip.is-retrying { animation: none; } }
.orch-result-text { margin: 0; color: var(--text-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.orch-result-error {
  text-align: left; padding: 0; border: 0; background: transparent; cursor: pointer; color: var(--danger); font-size: 0.75rem; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.orch-result-error:hover { text-decoration: underline; }
.orch-result-thumb { display: block; border-radius: 0.4rem; overflow: hidden; border: 1px solid var(--stroke); max-height: 7rem; }
.orch-result-thumb img { display: block; width: 100%; height: 7rem; object-fit: cover; }
.orch-result-file { color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orch-inspector-error {
  margin-bottom: 0.75rem; padding: 0.6rem 0.7rem; border-radius: 0.5rem; font-size: 0.8rem;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent); background: color-mix(in srgb, var(--danger) 8%, transparent);
}
.orch-inspector-error pre { margin: 0.35rem 0 0; white-space: pre-wrap; word-break: break-word; font-size: 0.75rem; color: var(--text-soft); }
.orch-wire-tip {
  position: absolute; z-index: 40; max-width: 18rem; pointer-events: none; display: grid; gap: 0.2rem;
  padding: 0.45rem 0.6rem; border-radius: 0.5rem; font-size: 0.75rem;
  background: var(--card-strong-bg); border: 1px solid var(--stroke-strong); box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.orch-wire-tip-label { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); }
.orch-wire-tip-value { color: var(--text); display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word; }

/* ── Reliability section in the inspector ───────────────────────────── */
.orch-reliability { margin-top: 1rem; border: 1px solid var(--stroke); border-radius: 0.6rem; padding: 0.4rem 0.75rem 0.75rem; }
.orch-reliability > summary { cursor: pointer; padding: 0.35rem 0; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-soft); }
.orch-reliability .orch-field { margin-top: 0.5rem; }
.orch-field-hint { display: block; margin-top: 0.25rem; font-size: 0.74rem; color: var(--text-faint); }

/* ── Estimate ───────────────────────────────────────────────────────── */
.orch-estimate-chip { gap: 0.35rem; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.orch-estimate-chip.uses-credits { border-color: var(--stroke-strong); }
.orch-estimate-pop {
  position: absolute; top: 0.6rem; right: 0.6rem; z-index: 31; width: min(30rem, calc(100% - 1.2rem)); max-height: 70%; overflow-y: auto;
  padding: 0.75rem 0.9rem; font-size: 0.82rem; color: var(--text-soft);
  background: var(--card-strong-bg); border: 1px solid var(--stroke-strong); border-radius: 0.65rem; box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.orch-estimate-pop header { display: flex; justify-content: space-between; color: var(--text); margin-bottom: 0.4rem; }
.orch-estimate-pop header span { color: var(--text-faint); font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 0.75rem; }
.orch-estimate-pop p { margin: 0 0 0.5rem; }
.orch-estimate-pop strong { color: var(--text); }
.orch-estimate-table { width: 100%; border-collapse: collapse; font-size: 0.78rem; }
.orch-estimate-table th, .orch-estimate-table td { padding: 0.35rem 0.4rem; border-top: 1px solid var(--stroke); text-align: left; vertical-align: top; }
.orch-estimate-table thead th { border-top: 0; font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.orch-estimate-table tbody th { font-weight: 600; color: var(--text); }
.orch-estimate-table td:nth-child(3), .orch-estimate-table td:nth-child(4) { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; white-space: nowrap; }
.orch-spend { display: inline-block; padding: 0.02rem 0.4rem; border-radius: 999px; font-size: 0.7rem; background: var(--chip-bg); border: 1px solid var(--chip-border); white-space: nowrap; }
.orch-spend-credits { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 35%, transparent); }
.orch-spend-local, .orch-spend-none { color: var(--text-faint); }
.orch-estimate-note { margin-top: 0.6rem !important; font-size: 0.74rem; color: var(--text-faint); }

/* ── Notes and groups ───────────────────────────────────────────────── */
.orch-annotation-layer { position: absolute; inset: 0; pointer-events: none; }
.orch-annotation-layer > * { pointer-events: auto; }
.orch-note {
  position: absolute; display: flex; flex-direction: column; border-radius: 0.5rem; overflow: hidden;
  background: color-mix(in srgb, var(--card-bg) 88%, var(--note-tint, var(--text-faint)));
  border: 1px solid color-mix(in srgb, var(--note-tint, var(--stroke-strong)) 55%, var(--stroke));
}
.orch-note-amber { --note-tint: var(--warning); }
.orch-note-green { --note-tint: var(--success); }
.orch-note-red { --note-tint: var(--danger); }
.orch-note-head { display: flex; justify-content: space-between; padding: 0.2rem 0.3rem; cursor: grab; border-bottom: 1px solid var(--stroke); }
.orch-note-btn { display: inline-flex; align-items: center; justify-content: center; width: 1.35rem; height: 1.35rem; border-radius: 0.35rem; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; }
.orch-note-btn:hover { background: var(--surface-highlight); color: var(--text); }
.orch-note-swatch { width: 0.65rem; height: 0.65rem; border-radius: 999px; background: var(--note-tint, var(--text-faint)); }
.orch-note-text { flex: 1; resize: none; border: 0; outline: none; padding: 0.45rem 0.6rem; background: transparent; color: var(--text); font: inherit; font-size: 0.82rem; line-height: 1.4; }
.orch-note-resize { position: absolute; right: 0; bottom: 0; width: 0.9rem; height: 0.9rem; cursor: nwse-resize; background: linear-gradient(135deg, transparent 50%, var(--stroke-strong) 50%); }
.orch-group {
  position: absolute; border-radius: 0.85rem;
  border: 1px dashed color-mix(in srgb, var(--group-tint, var(--text-faint)) 55%, transparent);
  background: color-mix(in srgb, var(--group-tint, var(--text-faint)) 5%, transparent);
}
.orch-group-green { --group-tint: var(--success); }
.orch-group-amber { --group-tint: var(--warning); }
.orch-group-red { --group-tint: var(--danger); }
.orch-group-head { display: flex; align-items: center; gap: 0.3rem; height: 30px; padding: 0 0.35rem; cursor: grab; }
.orch-group.is-collapsed { border-style: solid; background: var(--card-strong-bg); border-color: var(--stroke-strong); }
.orch-group.is-collapsed .orch-group-btn[data-orch-group-collapse] svg { transform: rotate(-90deg); }
.orch-group-btn { display: inline-flex; align-items: center; justify-content: center; width: 1.4rem; height: 1.4rem; border-radius: 0.35rem; border: 0; background: transparent; color: var(--text-faint); cursor: pointer; }
.orch-group-btn:hover { background: var(--surface-highlight); color: var(--text); }
.orch-group-label {
  min-width: 0; flex: 1; border: 1px solid transparent; border-radius: 0.35rem; background: transparent; color: var(--text);
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; padding: 0.1rem 0.3rem;
}
.orch-group-label:hover { border-color: var(--stroke); }
.orch-group-label:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.orch-group-count { font-size: 0.7rem; color: var(--text-faint); white-space: nowrap; }
.orch-node.is-group-hidden { display: none !important; }

/* ── Search ─────────────────────────────────────────────────────────── */
.orch-search {
  position: absolute; top: 0.6rem; left: 50%; transform: translateX(-50%); z-index: 32; display: flex; align-items: center; gap: 0.35rem;
  width: min(30rem, calc(100% - 1.2rem)); padding: 0.3rem 0.4rem 0.3rem 0.65rem;
  background: var(--card-strong-bg); border: 1px solid var(--stroke-strong); border-radius: 0.65rem; box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  color: var(--text-faint);
}
.orch-search-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; color: var(--text); font-size: 0.86rem; }
.orch-search-count { font-size: 0.74rem; color: var(--text-faint); white-space: nowrap; font-variant-numeric: tabular-nums; }
.living-graph-workspace .orch-node.is-search-match { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.living-graph-workspace .orch-node.is-search-current { box-shadow: 0 0 0 3px var(--accent), 0 0 24px color-mix(in srgb, var(--accent) 30%, transparent); }

/* ── Version diff ───────────────────────────────────────────────────── */
.orch-diff-bar {
  position: absolute; left: 50%; bottom: 0.8rem; transform: translateX(-50%); z-index: 32; display: flex; align-items: center; gap: 0.8rem;
  padding: 0.45rem 0.55rem 0.45rem 0.9rem; font-size: 0.82rem; color: var(--text);
  background: var(--card-strong-bg); border: 1px solid var(--stroke-strong); border-radius: 0.65rem; box-shadow: 0 12px 32px rgba(0,0,0,0.45);
}
.orch-diff-legend { display: inline-flex; align-items: center; gap: 0.35rem; color: var(--text-faint); font-size: 0.74rem; }
.orch-diff-legend i { display: inline-block; width: 0.65rem; height: 0.65rem; border-radius: 0.2rem; margin-left: 0.35rem; }
.orch-diff-legend .is-added { background: var(--success); }
.orch-diff-legend .is-changed { background: var(--warning); }
.orch-diff-legend .is-removed { background: var(--danger); }
.living-graph-workspace .orch-node.diff-added { border-color: var(--success); box-shadow: 0 0 0 3px color-mix(in srgb, var(--success) 22%, transparent); }
.living-graph-workspace .orch-node.diff-changed { border-color: var(--warning); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warning) 22%, transparent); }
.orch-diff-layer { position: absolute; inset: 0; pointer-events: none; }
.orch-diff-ghost {
  position: absolute; width: 240px; display: grid; gap: 0.2rem; padding: 0.6rem 0.75rem; border-radius: 0.85rem; opacity: 0.75;
  border: 1px dashed var(--danger); background: color-mix(in srgb, var(--danger) 6%, var(--card-bg));
}
.orch-diff-ghost-type { font-size: 0.66rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-faint); }
.orch-diff-ghost-title { font-size: 0.86rem; color: var(--text-soft); text-decoration: line-through; }
.orch-diff-ghost-tag { justify-self: start; font-size: 0.66rem; color: var(--danger); }
.living-graph-workspace .orch-edge.diff-added .orch-edge-path { stroke: var(--success); stroke-width: 2.5; }
.living-graph-workspace .orch-edge-removed .orch-edge-path { stroke: color-mix(in srgb, var(--danger) 75%, transparent); stroke-width: 2; stroke-dasharray: 4 5; }
.orch-version-diff { margin-left: auto; padding: 0.2rem 0.55rem; font-size: 0.75rem; }
.orch-run-row-failed { color: var(--danger); }

@media (max-width: 850px) {
  .orch-wiring-banner { flex-wrap: wrap; }
  .orch-diff-bar { flex-wrap: wrap; width: calc(100% - 1.2rem); }
  .orch-diff-legend { display: none; }
  .orch-estimate-chip span { display: none; }
}

/* ── Saved elsewhere (live-sync.js) ─────────────────────────────────── */
.orch-remote-notice {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.9rem; font-size: 0.82rem; color: var(--text-soft);
  background: color-mix(in srgb, var(--accent) 8%, var(--card-strong-bg)); border-bottom: 1px solid var(--stroke);
}
.orch-remote-notice > span { flex: 1; min-width: 0; }
@media (max-width: 850px) { .orch-remote-notice { flex-wrap: wrap; } }

/* Orchestration media bin (orchestration-media-bin.js). */
.orch-media-bin { display: flex; flex-direction: column; gap: 8px; width: min(340px, 42vw); flex: 0 0 auto; padding: 10px; border-left: 1px solid var(--stroke); background: var(--surface); overflow-y: auto; }
.orch-media-bin[hidden] { display: none; }
.orch-media-bin-head { display: flex; align-items: center; gap: 8px; }
.orch-media-bin-head strong { flex: 1; }
.orch-media-studio { padding: 4px 10px; font-size: 12.5px; }
.orch-media-hint { font-size: 12px; color: var(--text-muted); }
.orch-media-group h3 { font-size: 12px; font-weight: 600; margin: 8px 0 6px; }
.orch-media-group h3 small { font-weight: 400; color: var(--text-muted); }
.orch-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
.orch-media-item { position: relative; display: grid; gap: 3px; padding: 4px; border: 1px solid var(--stroke); border-radius: 6px; cursor: grab; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.orch-media-item img, .orch-media-item video { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 4px; background: #000; }
.orch-media-audio { display: grid; place-items: center; aspect-ratio: 16 / 10; font-size: 22px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 12%, transparent); }
.orch-media-name { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.orch-media-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 3px; }
.orch-media-actions button, .orch-media-actions a { width: 22px; height: 22px; display: grid; place-items: center; border: 0; border-radius: 4px; background: #000a; color: #fff; font-size: 13px; cursor: pointer; text-decoration: none; }
@media (max-width: 760px) { .orch-media-bin { position: absolute; inset: 0 0 0 auto; z-index: 30; width: min(340px, 92vw); } }

/* Orchestration media inside an orchestration ShadowStudio. */
.fireflea-media-group{display:grid;gap:6px;margin-bottom:8px}
.fireflea-media-group-title{font-size:11px;color:var(--text-muted);text-transform:uppercase;letter-spacing:.04em}
