/* FlowMation ticket canvas. Design kit: FlowMation brand tokens (Inter type,
   sage/sand/navy/lavender families, paper and card surfaces) implemented over
   the ticket-canvas spec. Message category keeps the spec blue #2f6fb0, the one
   hue our kit lacks. Category colour is never the only signal: every stub
   carries a glyph and every ticket a text tag. */

.fmc {
  --fmc-canvas: #e8efec;
  --fmc-dot: #c3d1cb;
  --fmc-card: #ffffff;
  --fmc-ink: #1f2933;
  --fmc-muted: #6f7c87;
  --fmc-line: #e5eae4;
  --fmc-wire: #8aa399;
  --fmc-accent: #3d7550;
  --fmc-accent-soft: #dceee1;
  --fmc-navy: #2b2140;
  --fmc-cat-trigger: #3d7550;
  --fmc-cat-logic: #946d31;
  --fmc-cat-message: #2f6fb0;
  --fmc-cat-data: #3b2e55;
  --fmc-cat-ai: #8f4773;
  --fmc-warn: #a2553f;
  --fmc-tag-size: 9px;
  --fmc-sentence-size: 11px;
  --fmc-tech-size: 8.5px;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--fmc-canvas);
  color: var(--fmc-ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: var(--fmc-sentence-size);
  touch-action: none;
  user-select: none;
}
/* Larger text scales type only. The box stays 150 x 66, so these values are
   sized to keep tag + two sentence lines + tech inside it without overflow. */
.fmc[data-fmc-large-text="1"] {
  --fmc-tag-size: 10px;
  --fmc-sentence-size: 12px;
  --fmc-tech-size: 9px;
}
.fmc[data-fmc-large-text="1"] .fmc-body {
  gap: 1px;
  padding-top: 3px;
  padding-bottom: 3px;
}
.fmc[data-fmc-theme="dark"] {
  --fmc-canvas: #0c161a;
  --fmc-dot: #22323a;
  --fmc-card: #17262d;
  --fmc-ink: #e6efeb;
  --fmc-muted: #9db3ac;
  --fmc-line: #243941;
  --fmc-wire: #4e6b73;
  --fmc-accent: #4cc38a;
  --fmc-accent-soft: #1d3a30;
  --fmc-warn: #e08f76;
}

.fmc-world {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}
.fmc-dots {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--fmc-dot) 1.1px, transparent 1.2px);
  background-size: 22px 22px;
  pointer-events: none;
}

/* Wires */
.fmc-wires {
  position: absolute;
  top: 0;
  left: 0;
  overflow: visible;
  pointer-events: none;
}
.fmc-wire {
  fill: none;
  stroke: var(--fmc-wire);
  stroke-width: 3.4;
  stroke-linecap: round;
}
.fmc-wire.is-dashed {
  stroke-dasharray: 3 7;
  opacity: 0.55;
}
.fmc-wire.is-active {
  stroke: var(--fmc-accent);
  stroke-width: 4.4;
  opacity: 1;
}
.fmc-wire.is-dim {
  opacity: 0.12;
}
.fmc-wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  pointer-events: stroke;
  cursor: pointer;
}
.fmc-wire.is-cut {
  stroke: var(--fmc-warn);
  stroke-width: 4.4;
}
.fmc-parcel {
  fill: var(--fmc-card);
  stroke: var(--fmc-line);
  stroke-width: 1;
}
.fmc-parcel-text {
  fill: var(--fmc-muted);
  font-size: 9px;
  font-weight: 600;
}
.fmc-wire-labels { position: absolute; inset: 0; pointer-events: none; }
.fmc-exit-label {
  position: absolute;
  display: block;
  max-width: 96px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--fmc-muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 14px;
  pointer-events: auto;
}

/* Tickets */
.fmc-ticket {
  position: absolute;
  width: 150px;
  height: 66px;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 11px;
  display: flex;
  overflow: visible;
  cursor: grab;
}
.fmc-ticket.is-selected {
  border-color: var(--fmc-accent);
  box-shadow: 0 0 0 2px var(--fmc-accent-soft);
}
.fmc-ticket.is-proposal-added,
.fmc-ticket.is-proposal-changed {
  cursor: default;
  border-style: dashed;
  box-shadow: 0 0 0 2px var(--fmc-accent-soft);
}
.fmc-ticket.is-proposal-removed {
  opacity: 0.38;
  border-style: dashed;
  cursor: default;
}
.fmc-ticket-badges {
  position: absolute;
  z-index: 3;
  top: -20px;
  left: 4px;
  display: flex;
  gap: 4px;
  white-space: nowrap;
}
.fmc-proposal-label,
.fmc-unreachable-label {
  border-radius: 5px;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  color: var(--fmc-ink);
  font-size: 10px;
  font-weight: 800;
  line-height: 15px;
  padding: 0 5px;
}
.fmc-unreachable-label { color: var(--fmc-warn); }
.fmc-ticket.is-proposal-removed .fmc-proposal-label {
  text-decoration: line-through;
}
.fmc-ticket.is-dim {
  opacity: 0.28;
}
.fmc-ticket.is-running {
  border-color: var(--fmc-accent);
  box-shadow: 0 0 0 2px var(--fmc-accent);
}
.fmc-ticket.is-done {
  border-color: var(--fmc-accent);
}
.fmc-ticket.is-failed {
  border-color: var(--fmc-warn);
  box-shadow: 0 0 0 2px rgba(162, 85, 63, 0.25);
}
.fmc-ticket.is-skipped {
  opacity: 0.45;
}
.fmc-ticket.is-match {
  box-shadow: 0 0 0 2px var(--fmc-cat-message);
}
.fmc-ticket:focus-visible {
  outline: 2px solid var(--fmc-accent);
  outline-offset: 2px;
}
.fmc-stub {
  width: 26px;
  flex: none;
  border-radius: 10px 0 0 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 15px;
  position: relative;
}
.fmc-stub::after {
  content: "";
  position: absolute;
  right: -1px;
  top: 6px;
  bottom: 6px;
  border-right: 2px dashed rgba(255, 255, 255, 0.55);
}
.fmc-stub-logo {
  display: flex;
  align-items: center;
  justify-content: center;
}
.fmc-stub-logo svg {
  display: block;
}
/* Single layer marks read as white silhouettes on the coloured stub. Marks
   inside [data-native-color] keep their own palette and skip the whitening. */
.fmc-stub-logo svg path:not([data-native-color] *) {
  fill: #ffffff;
}
.fmc-stub-logo svg image:not([data-native-color] *) {
  filter: brightness(0) invert(1);
}
/* Full colour and full bleed marks sit on a small white plate so the same
   artwork stays crisp on the light canvas and the dark canvas. */
.fmc-stub-logo.is-native {
  width: 18px;
  height: 18px;
  padding: 1.5px;
  box-sizing: border-box;
  background: #ffffff;
  border-radius: 4px;
  box-shadow: 0 0 0 1px rgba(20, 35, 45, 0.14);
}
.fmc-body {
  flex: 1;
  min-width: 0;
  padding: 4px 6px 4px 7px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.fmc-ticket.two .fmc-body {
  padding-right: 40px;
}
.fmc-tag {
  font-size: var(--fmc-tag-size);
  font-weight: 700;
  color: var(--fmc-muted);
  letter-spacing: 0;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fmc-sentence {
  font-size: var(--fmc-sentence-size);
  line-height: 1.35;
  color: var(--fmc-ink);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.fmc-chip {
  display: inline-block;
  max-width: 74px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  background: var(--fmc-accent-soft);
  color: var(--fmc-accent);
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 0 3px;
  font-weight: 600;
  cursor: text;
}
.fmc-chip:hover {
  border-color: var(--fmc-accent);
}
.fmc-chip-input {
  width: 68px;
  font-size: var(--fmc-sentence-size);
  border: 1px solid var(--fmc-accent);
  border-radius: 4px;
  padding: 0 2px;
}
.fmc-tech {
  display: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: var(--fmc-tech-size);
  color: var(--fmc-muted);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fmc[data-detail="near"] .fmc-tech,
.fmc[data-view="technical"] .fmc-tech {
  display: block;
}
.fmc[data-view="technical"] .fmc-sentence {
  display: none;
}
/* Three zoom tiers: near shows the full ticket, mid keeps the writeup, far
   collapses the ticket to its short label plus the stub. Ports and wires stay
   visible at every tier so the shape of the flow never disappears. */
.fmc-label {
  display: none;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fmc[data-detail="far"] .fmc-label {
  display: block;
}
.fmc[data-detail="far"] .fmc-tag,
.fmc[data-detail="far"] .fmc-sentence,
.fmc[data-detail="far"] .fmc-tech,
.fmc[data-detail="far"] .fmc-safety,
.fmc[data-detail="far"] .fmc-result,
.fmc[data-detail="far"] .fmc-info {
  display: none;
}
.fmc[data-detail="mid"] .fmc-tech {
  display: none;
}
.fmc[data-detail="mid"] .fmc-sentence {
  font-size: max(12px, var(--fmc-sentence-size));
}

/* Per-ticket info button and tooltip (developer-terms explanation) */
.fmc-info {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1px solid var(--fmc-line);
  background: var(--fmc-card);
  color: var(--fmc-muted);
  font-size: 9px;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  padding: 0;
  z-index: 3;
}
.fmc-info:hover,
.fmc-info:focus-visible {
  border-color: var(--fmc-accent);
  color: var(--fmc-accent);
}
.fmc-tooltip {
  position: absolute;
  z-index: 50;
  width: 280px;
  background: var(--fmc-navy);
  color: #f2f5f2;
  border-radius: 9px;
  padding: 10px 12px;
  box-shadow: 0 12px 30px rgba(20, 34, 43, 0.28);
  pointer-events: none;
}
.fmc-tooltip-head {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
  opacity: 0.75;
  margin-bottom: 5px;
}
.fmc-tooltip-sentence {
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 5px;
}
.fmc-tooltip-body {
  font-size: 11.5px;
  line-height: 1.5;
}
.fmc-tooltip-tech {
  margin-top: 7px;
  padding-top: 7px;
  border-top: 1px solid rgba(242, 245, 242, 0.18);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 9.5px;
  line-height: 1.55;
  opacity: 0.85;
  max-height: 96px;
  overflow: auto;
}

/* Money safety row */
.fmc-safety {
  position: absolute;
  top: 70px;
  left: 0;
  width: 150px;
  display: none;
  gap: 4px;
  align-items: center;
  font-size: 8.5px;
  color: var(--fmc-muted);
}
.fmc-ticket.is-money.is-selected .fmc-safety {
  display: flex;
}
.fmc-safety button {
  border: 1px solid var(--fmc-line);
  background: var(--fmc-card);
  color: var(--fmc-muted);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 8.5px;
}
.fmc-safety button.is-on {
  border-color: var(--fmc-accent);
  color: var(--fmc-accent);
  font-weight: 700;
}

/* Result line under the ticket after a run */
.fmc-result {
  position: absolute;
  top: 68px;
  left: 0;
  width: 150px;
  font-size: 9px;
  color: var(--fmc-muted);
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 6px;
  padding: 2px 6px;
}
.fmc-result.is-failed {
  color: var(--fmc-warn);
  border-color: var(--fmc-warn);
}

/* Ports */
.fmc-port {
  position: absolute;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fmc-card);
  border: 2px solid var(--fmc-wire);
  cursor: crosshair;
  z-index: 2;
}
.fmc-port.port-in {
  left: -6px;
  top: 27px;
}
.fmc-port.port-out {
  right: -6px;
  top: 27px;
}
.fmc-port.port-pass {
  right: -6px;
  top: 14px;
}
.fmc-port.port-fail {
  right: -6px;
  top: 40px;
}
.fmc-port:hover,
.fmc-port.is-armed {
  border-color: var(--fmc-accent);
  background: var(--fmc-accent);
}
.fmc-port.is-connected {
  background: var(--fmc-wire);
}

/* Bundles: stacked-look ticket */
.fmc-ticket.is-bundle .fmc-stub {
  border-radius: 10px 0 0 10px;
}
.fmc-ticket.is-bundle::before,
.fmc-ticket.is-bundle::after {
  content: "";
  position: absolute;
  inset: 3px -3px -3px 3px;
  border: 1px solid var(--fmc-line);
  border-radius: 11px;
  z-index: -1;
  background: var(--fmc-card);
}

/* Token (run replay) */
.fmc-token {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--fmc-accent);
  border: 2px solid var(--fmc-card);
  z-index: 5;
  pointer-events: none;
}

/* Marquee selection */
.fmc-marquee {
  position: absolute;
  border: 1.5px solid var(--fmc-accent);
  background: rgba(61, 117, 80, 0.08);
  pointer-events: none;
}

/* Toolbar chrome: one compact row */
.fmc-toolbar {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 20;
  flex-wrap: nowrap;
}
.fmc-group {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 9px;
  padding: 2px;
  flex: none;
}
.fmc-group label {
  font-size: 10px;
  color: var(--fmc-muted);
  padding: 0 3px;
  font-weight: 600;
}
.fmc-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--fmc-ink);
  border-radius: 6px;
  padding: 3px 7px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.fmc-btn:hover {
  background: var(--fmc-accent-soft);
  color: var(--fmc-accent);
}
.fmc-btn.is-on {
  background: var(--fmc-accent);
  color: #ffffff;
}
.fmc-btn:focus-visible,
.fmc-chip:focus-visible,
.fmc-mini:focus-visible {
  outline: 2px solid var(--fmc-accent);
  outline-offset: 1px;
}
.fmc-zoom-label {
  min-width: 78px;
  text-align: center;
  font-size: 10px;
  color: var(--fmc-muted);
  font-variant-numeric: tabular-nums;
}
.fmc-find {
  border: 1px solid var(--fmc-line);
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 11px;
  width: 118px;
  background: var(--fmc-card);
  color: var(--fmc-ink);
  flex: 0 1 auto;
  min-width: 84px;
}

/* More menu: the less-used canvas actions live here */
.fmc-more {
  position: relative;
  flex: none;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 9px;
  padding: 2px;
}
.fmc-more-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 168px;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 9px;
  padding: 4px;
  box-shadow: 0 10px 26px rgba(20, 34, 43, 0.16);
  z-index: 30;
}
.fmc-more-menu.is-open {
  display: block;
}
.fmc-more-menu .fmc-btn {
  display: block;
  width: 100%;
  text-align: left;
}

/* Mini-map */
.fmc-mini {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 168px;
  height: 108px;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 9px;
  z-index: 20;
  cursor: pointer;
}
.fmc-mini-rect {
  fill: var(--fmc-wire);
  opacity: 0.5;
}
.fmc-mini-node {
  fill: var(--fmc-wire);
  opacity: 0.55;
}
.fmc-mini-view {
  fill: none;
  stroke: var(--fmc-accent);
  stroke-width: 1.5;
}
.fmc-mini-label {
  fill: var(--fmc-muted);
  font-size: 8px;
  font-weight: 700;
}

/* Add-a-step picker */
.fmc-picker-back {
  position: absolute;
  inset: 0;
  background: rgba(20, 34, 43, 0.28);
  z-index: 40;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 56px;
}
.fmc-picker {
  width: min(460px, 92%);
  max-height: 70%;
  overflow: auto;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 12px;
  padding: 12px;
}
.fmc-picker input {
  width: 100%;
  border: 1px solid var(--fmc-line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: transparent;
  color: var(--fmc-ink);
}
.fmc-picker h5 {
  margin: 12px 0 4px;
  font-size: 10px;
  color: var(--fmc-muted);
  text-transform: none;
  letter-spacing: 0;
}
.fmc-pick {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
  padding: 7px 8px;
  font-size: 12px;
  color: var(--fmc-ink);
  cursor: pointer;
}
.fmc-pick:hover,
.fmc-pick:focus-visible {
  background: var(--fmc-accent-soft);
  color: var(--fmc-accent);
}

/* Bottom sheet (small screens) */
.fmc-sheet {
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  background: var(--fmc-card);
  border: 1px solid var(--fmc-line);
  border-radius: 12px;
  padding: 12px;
  z-index: 30;
  font-size: 12px;
  display: none;
}
.fmc-sheet.is-open {
  display: block;
}
.fmc-sheet h4 {
  margin: 0 0 6px;
  font-size: 13px;
}
.fmc-sheet .fmc-tech {
  display: block;
  max-height: 84px;
  overflow: auto;
  margin-top: 8px;
}

@media (max-width: 720px) {
  .fmc-mini {
    display: none;
  }
  .fmc-find {
    width: 96px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fmc-token {
    display: none;
  }
}

/* End is a terminal stroke with text, not a stored ticket or a pill. */
.fmc-end-mark {
  fill: none;
  stroke: var(--fmc-muted);
  stroke-width: 2;
}
.fmc-end-label {
  fill: var(--fmc-muted);
  font-size: 10px;
  font-weight: 700;
}
.fmc-end-drop {
  position: absolute;
  z-index: 20;
  right: 24px;
  bottom: 24px;
  padding: 14px 22px;
  border: 2px dashed var(--fmc-accent);
  border-radius: 3px;
  background: var(--fmc-card);
  color: var(--fmc-ink);
  font-size: 13px;
  font-weight: 700;
}
.fmc-end-drop[hidden] { display: none; }
.fmc-end-drop:hover { background: var(--fmc-accent-soft); }
.fmc-port[data-port^="case:"], .fmc-port[data-port="default"] { transform: translateY(-50%); }
.fmc-ticket .fmc-port.port-in { top: calc(50% - 6px); }
.fmc-ticket .fmc-result { top: calc(100% + 3px); }

.fmc-loop-frames { position: absolute; top: 0; left: 0; pointer-events: none; }
.fmc-loop-frame { position: absolute; box-sizing: border-box; border: 1px solid var(--fmc-wire); border-radius: 12px; pointer-events: none; }
.fmc-loop-frame-label { position: absolute; top: 0; left: 8px; color: var(--fmc-wire); font-size: 10px; }
