/* AgentOps intro overlays on top of vendored FlowStory chrome. */

.fs-header-stack {
  position: fixed;
  top: 10px;
  z-index: 200;
  pointer-events: none;
  text-align: center;
  width: max-content;
  /* left + transform set by syncScenarioHeaderLayout() */
}

.fs-header-stack .fs-title {
  position: static;
  left: auto;
  right: auto;
  width: auto;
  font-size: 18px;
  top: auto;
}

.fs-header-stack .fs-tagline {
  position: static;
  left: auto;
  right: auto;
  margin-top: 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--fs-text-dim);
}

.fs-title {
  font-size: 18px;
  top: 10px;
}

.fs-inspector-title {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* Flow bar dock — always under the header */
body.fs-has-top-panel .fs-top-dock {
  position: fixed;
  top: 52px;
  left: 0;
  right: 0;
  z-index: 131;
  background: var(--fs-bg-surface);
  border-bottom: 1px solid var(--fs-border);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.14);
}

body.fs-has-top-panel .fs-top-dock .fs-panel {
  position: static;
  top: auto;
  right: auto;
  width: 100%;
  height: auto;
  border-left: none;
  display: block;
  overflow: visible;
}

body.fs-has-top-panel .fs-top-dock .fs-flow-bar {
  flex-shrink: 0;
  border-bottom: none;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  overflow-y: hidden;
}

body.fs-has-top-panel .fs-top-dock .fs-flow-nav {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  max-width: none;
}

body.fs-has-top-panel .fs-top-dock .fs-flow-bar select {
  flex: 1 1 auto;
  min-width: 7.5rem;
  max-width: none;
  padding: 6px 8px;
  font-size: 12px;
}

body.fs-has-top-panel .fs-top-dock .fs-flow-bar button {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 6px 10px;
  font-size: 12px;
}

body.fs-has-top-panel .fs-top-dock .fs-flow-nav #fs-prev,
body.fs-has-top-panel .fs-top-dock .fs-flow-nav #fs-next {
  flex: 0 0 30px;
  min-width: 30px;
  padding: 6px 4px;
}

body.fs-has-top-panel .fs-top-dock .fs-flow-nav #fs-play {
  flex: 0 0 auto;
  min-width: 58px;
  padding: 6px 8px;
  font-size: 12px;
}

/* Legend — top-left gap in diagram area (below flow / layers chrome) */
body.fs-has-top-panel .fs-legend--diagram-inset {
  position: fixed;
  top: calc(var(--fs-chrome-top-offset, 52px) + 10px);
  left: 16px;
  right: auto;
  bottom: auto;
  z-index: 125;
  width: min(168px, 20vw);
  max-height: min(
    240px,
    calc(100vh - var(--fs-chrome-top-offset, 52px) - var(--fs-chrome-bottom-offset, 0px) - 56px)
  );
  overflow-x: hidden;
  overflow-y: auto;
  padding: 8px 10px;
  margin: 0;
  font-size: 10px;
  line-height: 1.35;
  pointer-events: auto;
}

body.fs-has-top-panel .fs-legend--diagram-inset .fs-legend-title {
  font-size: 11px;
  margin-bottom: 4px;
}

body.fs-has-top-panel .fs-legend--diagram-inset .fs-legend-item {
  font-size: 10px;
  margin: 2px 0;
  gap: 5px;
}

body.fs-has-top-panel .fs-legend--diagram-inset .fs-legend-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
}

/* Layers dock — right (default), top, or bottom */
body.fs-has-top-panel .fs-layers-dock {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 130;
  background: var(--fs-bg-surface);
  height: calc(var(--fs-layers-panel-height, 10rem) * 2);
  overflow: hidden;
}

body.fs-layers-pos-right .fs-layers-dock {
  top: var(--fs-flow-dock-offset, 52px);
  bottom: 0;
  left: auto;
  width: var(--fs-layers-right-width, 380px);
  height: auto;
  border-left: 1px solid var(--fs-border);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.18);
}

body.fs-layers-pos-right .fs-layers-stack .fs-steps {
  flex: 2 1 0;
  max-height: none;
  overflow-y: auto;
}

body.fs-layers-pos-right .fs-layers-stack .fs-inspector {
  flex: 3 1 0;
  max-height: none;
  overflow-y: auto;
}

body.fs-layers-pos-top .fs-layers-dock {
  top: var(--fs-flow-dock-offset, 52px);
  border-bottom: 1px solid var(--fs-border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

body.fs-layers-pos-bottom .fs-layers-dock {
  bottom: 0;
  top: auto;
  border-top: 1px solid var(--fs-border);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.18);
}

body.fs-has-top-panel .fs-layers-stack {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

body.fs-has-top-panel .fs-layers-stack .fs-steps,
body.fs-has-top-panel .fs-layers-stack .fs-inspector {
  flex: 1 1 0;
  min-height: 0;
  max-height: 50%;
  overflow-x: hidden;
}

body.fs-has-top-panel .fs-layers-stack .fs-steps {
  padding: 8px 12px;
  overflow-y: auto;
  border-bottom: 1px solid var(--fs-border);
}

body.fs-has-top-panel .fs-layers-stack .fs-inspector {
  padding: 8px 12px;
  overflow-y: hidden;
}

body.fs-layers-ui--off .fs-layers-dock {
  display: none;
}

body.fs-has-top-panel .fs-theme-toggle {
  top: calc(var(--fs-chrome-top-offset, 52px) + 8px);
  right: 16px;
}

body.fs-has-top-panel #fs-overlay {
  top: var(--fs-chrome-top-offset, 52px) !important;
  bottom: var(--fs-chrome-bottom-offset, 0px) !important;
  right: 0 !important;
}

body.fs-layers-pos-right:not(.fs-layers-ui--off) #fs-overlay {
  right: var(--fs-layers-right-width, 380px) !important;
}

body.fs-has-top-panel .fs-credit {
  bottom: calc(16px + var(--fs-chrome-bottom-offset, 0px));
}

body.fs-layers-pos-right:not(.fs-layers-ui--off) .fs-theme-toggle {
  right: calc(var(--fs-layers-right-width, 380px) + 16px);
}

#fs-layers-toggle.fs-layers-toggle--right {
  border-color: #d2a8ff;
  color: #d2a8ff;
}

#fs-layers-toggle.fs-layers-toggle--top {
  border-color: #3fb950;
  color: #3fb950;
}

#fs-layers-toggle.fs-layers-toggle--bottom {
  border-color: #79c0ff;
  color: #79c0ff;
}

.fs-legend {
  left: auto;
  right: 16px;
  bottom: 16px;
}

.fs-credit {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 100;
  font-size: 11px;
  color: var(--fs-text-muted);
}

.fs-credit a {
  color: var(--fs-accent);
  text-decoration: none;
}

/* Flow hop row: dropdown + prev/play/next stay on one line (scenario side panels) */
.fs-flow-nav {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

body:not(.fs-has-top-panel) .fs-flow-nav {
  width: 100%;
  flex: 1 1 100%;
}

.fs-flow-bar select {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  max-width: none;
  padding: 7px 8px;
  font-size: 12px;
}

.fs-flow-nav #fs-prev,
.fs-flow-nav #fs-next {
  flex: 0 0 32px;
  min-width: 32px;
  padding: 7px 6px;
}

.fs-flow-nav #fs-play {
  flex: 0 0 auto;
  min-width: 68px;
  padding: 7px 8px;
  font-size: 12px;
}

#fs-response-mode.fs-response-mode-on {
  border-color: #3fb950;
  color: #3fb950;
}

.fs-node-popup {
  position: fixed;
  z-index: 500;
  max-width: 280px;
  pointer-events: none;
  display: block;
}

.fs-node-popup-inner {
  position: relative;
  background: #161b22f0;
  border: 1px solid #30363d;
  border-radius: 10px;
  padding: 10px 12px 10px 14px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
}

.fs-node-popup-accent {
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 2px;
  background: #58a6ff;
}

.fs-node-popup-title {
  font-size: 12px;
  font-weight: 600;
  color: #c9d1d9;
  margin-bottom: 6px;
  line-height: 1.3;
}

.fs-node-popup-lines {
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: #8b949e;
  line-height: 1.45;
}

.fs-node-popup-line + .fs-node-popup-line {
  margin-top: 3px;
}

.fs-inspector-section.fs-inspector-responses + .fs-inspector-lines,
.fs-inspector-section.fs-inspector-responses ~ .fs-inspector-lines {
  font-family: "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: var(--fs-text-dim);
}

/* Scenario panels (A–D) + links from overall architecture */
.fs-scenario-nav {
  position: fixed;
  top: 52px;
  /* left + transform set by syncScenarioHeaderLayout() */
  z-index: 200;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  max-width: 92vw;
  pointer-events: auto;
}

.fs-scenario-nav a {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--fs-border);
  color: var(--fs-text-dim);
  text-decoration: none;
  background: var(--fs-panel-bg, #161b22cc);
}

.fs-scenario-nav a:hover {
  border-color: var(--fs-accent);
  color: var(--fs-accent);
}

.fs-scenario-nav a.active {
  border-color: #79c0ff;
  color: #79c0ff;
}

.fs-scenario-nav a.fs-overall-link {
  border-color: var(--fs-text-muted);
}

.fs-mode-toggle {
  display: flex;
  gap: 4px;
  margin-right: 6px;
  flex-shrink: 0;
  flex: 1 1 100%;
}

.fs-mode-toggle[hidden] {
  display: none;
}

.fs-mode-toggle button {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  min-width: 64px;
  border-radius: 6px;
  border: 1px solid var(--fs-border);
  background: transparent;
  color: var(--fs-text-dim);
  cursor: pointer;
}

.fs-mode-toggle button[data-fs-mode="before"].active {
  border-color: #d29922;
  color: #d29922;
  background: rgba(210, 153, 34, 0.14);
}

.fs-mode-toggle button[data-fs-mode="after"].active {
  border-color: #3fb950;
  color: #3fb950;
  background: rgba(63, 185, 80, 0.14);
}

body.fs-scenario-phase-before #fs-canvas {
  box-shadow: inset 0 0 120px rgba(210, 153, 34, 0.07);
}

body.fs-scenario-phase-after #fs-canvas {
  box-shadow: inset 0 0 120px rgba(63, 185, 80, 0.07);
}

.fs-credit-scenario {
  position: fixed;
  bottom: 16px;
  left: 16px;
  z-index: 100;
  font-size: 11px;
  color: var(--fs-text-muted);
}

.fs-credit-scenario a {
  color: var(--fs-accent);
  text-decoration: none;
}

/* FlowStory chrome — overlay, highlight, loop, hints (shared markup) */

#fs-loop {
  border-color: #79c0ff;
  color: #79c0ff;
}

.fs-steps-title .fs-steps-hint {
  font-weight: 400;
  font-size: 11px;
  color: var(--fs-text-dim);
}

#fs-inspector-title {
  color: var(--fs-accent);
}

#fs-highlight-box {
  display: none;
  position: fixed;
  z-index: 350;
  border-radius: 10px;
  pointer-events: none;
}

#fs-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 380px;
  bottom: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.6);
}

#fs-overlay-card {
  position: absolute;
  background: #161b22ee;
  border: 1px solid #30363d;
  border-radius: 14px;
  max-width: 420px;
  padding: 22px 26px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  transition: opacity 0.2s;
}

#fs-overlay-close {
  position: absolute;
  top: 10px;
  right: 14px;
  background: none;
  border: none;
  color: #8b949e;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}

#fs-overlay-accent {
  width: 4px;
  height: 24px;
  border-radius: 2px;
  position: absolute;
  left: 0;
  top: 22px;
}

#fs-overlay-title {
  margin: 0 0 6px;
  font-size: 18px;
  color: #c9d1d9;
  font-family: system-ui, -apple-system, sans-serif;
}

#fs-overlay-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: #8b949e;
  line-height: 1.5;
  font-family: system-ui, -apple-system, sans-serif;
}

#fs-overlay-details {
  font-size: 12px;
  font-family: "SF Mono", Menlo, monospace;
}

#fs-overlay-resume {
  margin-top: 14px;
  padding: 7px 20px;
  border: 1px solid #3fb950;
  border-radius: 8px;
  background: transparent;
  color: #3fb950;
  font-size: 13px;
  cursor: pointer;
  font-family: system-ui, -apple-system, sans-serif;
}

.fs-load-error {
  padding: 24px;
  color: #f85149;
}

/* Ephemeral proxy-offline hint (fixed; no document flow) */
.nr-proxy-offline-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  z-index: 400;
  max-width: min(520px, calc(100vw - 32px));
  padding: 10px 14px;
  font-size: 12px;
  line-height: 1.45;
  color: #8a4b00;
  background: #fff8e6;
  border: 1px solid #f0d9a8;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  pointer-events: none;
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
  animation: nr-proxy-offline-toast 5s ease forwards;
}

@keyframes nr-proxy-offline-toast {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(8px);
  }
  8% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  75% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(4px);
  }
}
