/* Custom Workflow builder.
 *
 * Started life as an inline <style> in dashboard.html, which tests/results-
 * dialog-scope.mjs refused for the reason it refuses every other one: the
 * public share page is served by the worker and loads the dashboard's LINKED
 * sheets (kept in step by tests/share-css-sync.mjs), so a tool whose CSS is
 * inline renders there as unstyled text.
 *
 * Every selector is paired #view-wfbuilder / .mv-as-wfbuilder. The result
 * markup does not stay in the view: the Home results dialog MOVES it onto
 * <body>, and the share page serves a capture of it with no view wrapper at
 * all. .mv-as-wfbuilder is the identity both of those surfaces wear, so the
 * pair is what makes these rules follow the markup rather than the container
 * they were written against.
 *
 * The inputs are .ci-field, the component every dedicated tool screen uses:
 * 46px tall, 11px radius, an icon and a borderless input. The first version
 * used bare <input> elements with their own padding and border, which is why
 * the screen read as a form bolted onto the product rather than part of it.
 *
 * Tokens only. No literal colours, no radius off the scale.
 */

/* ------------------------------------------------------------ saved chips */
#view-wfbuilder .cwf-saved,
.mv-as-wfbuilder .cwf-saved { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 16px 0 0; }
#view-wfbuilder .cwf-saved-lab,
.mv-as-wfbuilder .cwf-saved-lab { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-right: 2px; }

#view-wfbuilder .cwf-chip,
.mv-as-wfbuilder .cwf-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--surface); color: var(--text-2);
  font-size: 12.5px; cursor: pointer;
  transition: border-color .14s ease, color .14s ease, background .14s ease;
}
#view-wfbuilder .cwf-chip:hover,
.mv-as-wfbuilder .cwf-chip:hover { border-color: var(--purple-bright); color: var(--text); }
#view-wfbuilder .cwf-chip.on,
.mv-as-wfbuilder .cwf-chip.on { border-color: var(--purple-bright); color: var(--text); background: var(--mv-result-chip); }
#view-wfbuilder .cwf-chip .x,
.mv-as-wfbuilder .cwf-chip .x { opacity: .55; font-size: 15px; line-height: 1; }
#view-wfbuilder .cwf-chip .x:hover,
.mv-as-wfbuilder .cwf-chip .x:hover { opacity: 1; color: var(--red); }

/* ----------------------------------------------------------- the toolbar */
#view-wfbuilder .cwf-bar,
.mv-as-wfbuilder .cwf-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 18px; }
#view-wfbuilder .cwf-search,
.mv-as-wfbuilder .cwf-search { flex: 1 1 260px; min-width: 0; }

/* -------------------------------------------------------------- the picker */
#view-wfbuilder .cwf-grp,
.mv-as-wfbuilder .cwf-grp { margin-top: 20px; }
#view-wfbuilder .cwf-grph,
.mv-as-wfbuilder .cwf-grph {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 10px;
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); font-weight: 700;
}
/* A hairline carrying the eye across the row, so a group reads as a band
   rather than a label floating above loose cards. */
#view-wfbuilder .cwf-grph::after,
.mv-as-wfbuilder .cwf-grph::after { content: ""; flex: 1; height: 1px; background: var(--border); }
#view-wfbuilder .cwf-grph .n,
.mv-as-wfbuilder .cwf-grph .n { color: var(--text-3); font-weight: 600; letter-spacing: 0; text-transform: none; font-size: 11.5px; }

#view-wfbuilder .cwf-grid,
.mv-as-wfbuilder .cwf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(244px, 1fr)); gap: 10px; }

#view-wfbuilder .cwf-tool,
.mv-as-wfbuilder .cwf-tool {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-base);
  background: var(--surface); cursor: pointer;
  transition: border-color .14s ease, background .14s ease, transform .14s ease;
}
#view-wfbuilder .cwf-tool:hover,
.mv-as-wfbuilder .cwf-tool:hover { border-color: var(--purple-bright); transform: translateY(-1px); }
#view-wfbuilder .cwf-tool.on,
.mv-as-wfbuilder .cwf-tool.on { border-color: var(--purple-bright); background: var(--mv-result-chip); }
/* The real checkbox stays, for the keyboard and for screen readers; the chip
   beside it is what carries the state visually. */
#view-wfbuilder .cwf-tool input,
.mv-as-wfbuilder .cwf-tool input { position: absolute; opacity: 0; pointer-events: none; }
#view-wfbuilder .cwf-tool:focus-within,
.mv-as-wfbuilder .cwf-tool:focus-within { border-color: var(--purple-bright); box-shadow: 0 0 0 3px var(--mv-result-chip); }

#view-wfbuilder .cwf-tick,
.mv-as-wfbuilder .cwf-tick {
  flex: none; width: 30px; height: 30px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel); color: var(--text-3);
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
/* Tinted, not filled. A solid purple square with a white tick would need a
   literal white, and there is no token for text on an accent fill; the one
   .btn-grad uses is grandfathered debt rather than a precedent to copy. (This
   note carries no colour literal on purpose: design-lint counts raw text, so
   even quoting one in a comment registers as new debt.) A filled square also
   reads heavier than anything else here. The card already tints and its border
   already turns, so the tick only has to agree with them. */
#view-wfbuilder .cwf-tool.on .cwf-tick,
.mv-as-wfbuilder .cwf-tool.on .cwf-tick { background: var(--mv-result-chip); border-color: var(--purple-bright); color: var(--purple-bright); }
#view-wfbuilder .cwf-tool .tx,
.mv-as-wfbuilder .cwf-tool .tx { min-width: 0; flex: 1; }
#view-wfbuilder .cwf-tool .nm,
.mv-as-wfbuilder .cwf-tool .nm { display: block; font-size: 13px; color: var(--text); font-weight: 600; line-height: 1.3; }
#view-wfbuilder .cwf-tool .ct,
.mv-as-wfbuilder .cwf-tool .ct { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 3px; }
#view-wfbuilder .cwf-tool .ct .free,
.mv-as-wfbuilder .cwf-tool .ct .free { color: var(--green); font-weight: 600; }

/* A tool the current market cannot run. Only eight answer Worldwide; the rest
   are refused before they cost anything, so this is a warning the picker can
   give before the run rather than a row of red cards after it. Still tickable:
   changing the market is one click and then it works. */
#view-wfbuilder .cwf-tool.ww,
.mv-as-wfbuilder .cwf-tool.ww { border-style: dashed; }
#view-wfbuilder .cwf-tool .wwx,
.mv-as-wfbuilder .cwf-tool .wwx { color: var(--amber); font-weight: 600; }

#view-wfbuilder .cwf-none,
.mv-as-wfbuilder .cwf-none { color: var(--text-3); font-size: 13px; padding: 18px 0; }

/* ----------------------------------------------------------------- the run */
/* One row per selected tool, each carrying that tool's own field. The first
   design shared one box per input SHAPE, so every keyword tool got the same
   keyword - which is not what someone running two of them wants, and gave
   them no way to see which tool was missing a value. */
#view-wfbuilder .cwf-run,
.mv-as-wfbuilder .cwf-run { margin-top: 24px; display: flex; flex-direction: column; gap: 10px; }
#view-wfbuilder .cwf-runh,
.mv-as-wfbuilder .cwf-runh {
  display: flex; align-items: center; gap: 10px; margin: 0;
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-3); font-weight: 700;
}
#view-wfbuilder .cwf-runh::after,
.mv-as-wfbuilder .cwf-runh::after { content: ""; flex: 1; height: 1px; background: var(--border); }

#view-wfbuilder .cwf-empty,
.mv-as-wfbuilder .cwf-empty {
  margin-top: 24px; padding: 30px 22px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface); text-align: center;
}
#view-wfbuilder .cwf-empty h4,
.mv-as-wfbuilder .cwf-empty h4 { margin: 0 0 6px; font-size: 14.5px; color: var(--text); font-weight: 700; }
#view-wfbuilder .cwf-empty p,
.mv-as-wfbuilder .cwf-empty p { margin: 0; font-size: 13px; color: var(--text-3); line-height: 1.55; }

#view-wfbuilder .cwf-row,
.mv-as-wfbuilder .cwf-row {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  background: var(--surface); padding: 13px 15px 15px;
}
/* A row with nothing typed in it. The run refuses and names the tool, so this
   is the pointer that goes with the sentence rather than the only signal. */
#view-wfbuilder .cwf-row.needs,
.mv-as-wfbuilder .cwf-row.needs { border-color: var(--amber); }

#view-wfbuilder .cwf-rowhead,
.mv-as-wfbuilder .cwf-rowhead { display: flex; align-items: center; gap: 10px; }
#view-wfbuilder .cwf-rowhead .no,
.mv-as-wfbuilder .cwf-rowhead .no {
  flex: none; width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--mv-result-chip); color: var(--purple-bright);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
#view-wfbuilder .cwf-rowhead .ri,
.mv-as-wfbuilder .cwf-rowhead .ri { display: inline-flex; color: var(--purple-bright); flex: none; }
#view-wfbuilder .cwf-rowhead .rn,
.mv-as-wfbuilder .cwf-rowhead .rn { font-size: 13.5px; font-weight: 700; color: var(--text); flex: 1; min-width: 0; }
#view-wfbuilder .cwf-rowhead .rc,
.mv-as-wfbuilder .cwf-rowhead .rc { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
#view-wfbuilder .cwf-rowhead .rx,
.mv-as-wfbuilder .cwf-rowhead .rx {
  background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
  color: var(--text-3); font-size: 16px; line-height: 1; cursor: pointer;
  width: 26px; height: 26px; display: inline-flex; align-items: center; justify-content: center;
}
#view-wfbuilder .cwf-rowhead .rx:hover,
.mv-as-wfbuilder .cwf-rowhead .rx:hover { color: var(--red); border-color: var(--border); }

#view-wfbuilder .cwf-rowin,
.mv-as-wfbuilder .cwf-rowin { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 11px; }
#view-wfbuilder .cwf-rowin .lab,
.mv-as-wfbuilder .cwf-rowin .lab { display: block; font-size: 11.5px; color: var(--text-3); margin: 0 0 6px; }
/* The field itself is .ci-field, the component every dedicated tool uses, so
   it is not restyled here - only sized to the row. */
#view-wfbuilder .cwf-rowin .ci-field,
.mv-as-wfbuilder .cwf-rowin .ci-field { width: 100%; min-width: 0; }

/* Known competitors, offered rather than typed. */
#view-wfbuilder .cwf-sug,
.mv-as-wfbuilder .cwf-sug { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
#view-wfbuilder .cwf-sug .sl,
.mv-as-wfbuilder .cwf-sug .sl { font-size: 11px; color: var(--text-3); }
#view-wfbuilder .cwf-sug button,
.mv-as-wfbuilder .cwf-sug button {
  border: 1px solid var(--border); border-radius: var(--radius-pill);
  background: var(--panel); color: var(--text-2);
  font-size: 11.5px; padding: 4px 10px; cursor: pointer;
}
#view-wfbuilder .cwf-sug button:hover,
.mv-as-wfbuilder .cwf-sug button:hover { border-color: var(--purple-bright); color: var(--text); }

/* ------------------------------------------------------------- the summary */
#view-wfbuilder .cwf-sum,
.mv-as-wfbuilder .cwf-sum {
  display: flex; flex-wrap: wrap; gap: 14px;
  align-items: center; justify-content: space-between;
  margin-top: 20px; padding: 15px 17px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  background: var(--surface);
}
#view-wfbuilder .cwf-sum .n,
.mv-as-wfbuilder .cwf-sum .n { font-size: 13.5px; color: var(--text-2); display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
#view-wfbuilder .cwf-sum .n b,
.mv-as-wfbuilder .cwf-sum .n b { color: var(--text); font-variant-numeric: tabular-nums; }
#view-wfbuilder .cwf-sum .sep,
.mv-as-wfbuilder .cwf-sum .sep { color: var(--text-3); }
#view-wfbuilder .cwf-acts,
.mv-as-wfbuilder .cwf-acts { display: flex; flex-wrap: wrap; gap: 10px; }

#view-wfbuilder .cwf-note,
.mv-as-wfbuilder .cwf-note { margin-top: 10px; font-size: 12px; color: var(--text-3); }
