.canvas-viewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: default;
}

.director-flow,
.director-flow .react-flow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.director-flow .react-flow__renderer {
  cursor: default;
}

body[aria-busy="true"] .director-flow {
  pointer-events: none;
  opacity: .78;
}

.director-flow.tool-hand .react-flow__pane {
  cursor: grab;
}

.director-flow.tool-hand .react-flow__pane:active {
  cursor: grabbing;
}

.director-flow .react-flow__node {
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: default;
}

.director-flow .react-flow__node-director,
.director-flow .react-flow__node-dynamic {
  width: 100%;
  height: 100%;
}

.director-flow .node {
  position: relative;
  inset: auto;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: visible;
  transform-origin: center;
  transition: border-color 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.director-flow .node > header.node-drag-handle {
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.director-flow .node > header.node-drag-handle:active {
  cursor: grabbing;
}

.director-flow .react-flow__node.dragging .node {
  filter: brightness(1.08);
  box-shadow: 0 24px 70px #000c, 0 0 0 1px #d9ff5555;
}

.director-flow .node.selected,
.director-flow .react-flow__node.selected .node {
  border-color: var(--lime);
  box-shadow: 0 0 0 2px #d9ff5533, 0 18px 42px #0009;
}

.director-flow .source-node {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) auto;
}

.source-image-button {
  position: relative;
  width: 100%;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #fff;
  cursor: pointer;
}

.source-image-button img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.source-image-button span {
  position: absolute;
  right: 10px;
  bottom: 10px;
  padding: 5px 8px;
  border: 1px solid #ffffff33;
  border-radius: 6px;
  background: #090c10cc;
  color: #f5f8fa;
  font-size: 12px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.source-image-button:hover span,
.source-image-button:focus-visible span {
  opacity: 1;
  transform: translateY(0);
}

.director-flow .result-node {
  display: grid;
  grid-template-rows: 34px minmax(0, 1fr) auto auto;
}

.director-flow .result-node .image-wrap {
  height: auto;
  min-height: 0;
  transform-origin: center;
}

.director-flow .result-node .image-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.director-flow .evidence-node,
.director-flow .prompt-node {
  display: flex;
  flex-direction: column;
}

.director-flow .evidence-node ul,
.director-flow .prompt-node p {
  min-height: 0;
  overflow: hidden;
}

.director-flow .evidence-node footer,
.director-flow .prompt-node footer {
  margin-top: auto;
}

.director-handle {
  z-index: 12 !important;
  width: 10px !important;
  height: 10px !important;
  border: 2px solid #11161b !important;
  background: #85939f !important;
  opacity: .35;
  transition: opacity 120ms ease, transform 120ms ease, background 120ms ease;
}

.react-flow__node:hover .director-handle,
.react-flow__node.selected .director-handle {
  opacity: 1;
  transform: scale(1.15);
  background: var(--lime) !important;
}

.director-resize-line {
  border-color: #d9ff55 !important;
}

.director-resize-handle {
  width: 9px !important;
  height: 9px !important;
  border: 2px solid #11161b !important;
  border-radius: 50% !important;
  background: #d9ff55 !important;
}

.node-context-menu {
  position: absolute;
  top: 30px;
  right: 6px;
  z-index: 30;
  display: grid;
  width: 168px;
  padding: 6px;
  border: 1px solid #3a4651;
  border-radius: 10px;
  background: rgba(20, 25, 30, .97);
  box-shadow: 0 20px 60px #000c;
  backdrop-filter: blur(16px) saturate(150%);
  transform-origin: top right;
  animation: menu-in 120ms ease-out;
}

.director-flow .react-flow__node-result .node-context-menu {
  right: calc(100% + 8px);
}

.node-context-menu button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #dbe2e8;
  text-align: left;
}

.node-context-menu button:hover,
.node-context-menu button:focus-visible {
  background: #2a323a;
  outline: none;
}

.node-context-menu button:disabled,
.director-flow .node-actions button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

.dynamic-node-actions {
  display: flex;
  gap: 6px;
  padding: 0 10px 4px;
}

.dynamic-node-actions button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid #44515d;
  border-radius: 6px;
  background: #20272e;
  color: #d9ff55;
  font-size: 12px;
}

.canvas-toolbar .tool:disabled {
  cursor: not-allowed;
  opacity: .38;
}

.node-context-menu button.danger {
  color: #ff8e8e;
}

.canvas-add-menu {
  position: fixed;
  z-index: 100;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  width: 286px;
  padding: 8px;
  border: 1px solid #3c4955;
  border-radius: 12px;
  background: rgba(18, 23, 28, .97);
  box-shadow: 0 24px 72px #000d;
  backdrop-filter: blur(20px) saturate(150%);
  transform: translate(8px, 8px);
  transform-origin: top left;
  animation: menu-in 120ms ease-out;
}

.canvas-add-menu > span {
  grid-column: 1 / -1;
  padding: 5px 7px 3px;
  color: #8e9aa5;
  font-size: 12px;
}

.canvas-add-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  background: #20272e;
  color: #eef2f4;
}

.canvas-add-menu button:hover,
.canvas-add-menu button:focus-visible {
  background: #303a43;
  outline: 2px solid #d9ff5566;
}

.canvas-add-menu b {
  color: var(--lime);
  font-size: 18px;
}

.dynamic-node {
  display: grid;
  grid-template-rows: 34px auto minmax(48px, 1fr);
  overflow: hidden !important;
}

.dynamic-node-image {
  width: 100%;
  max-height: 54%;
  object-fit: contain;
  background: #0e1216;
}

.dynamic-title,
.dynamic-body {
  width: calc(100% - 20px);
  margin: 8px 10px 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #eef2f4;
  font: inherit;
}

.dynamic-title {
  min-height: 28px;
  padding: 4px 6px;
  font-weight: 700;
}

.dynamic-body {
  min-height: 44px;
  margin-bottom: 9px;
  padding: 5px 6px;
  resize: none;
  color: #aeb8c1;
  line-height: 1.45;
}

.dynamic-title:hover,
.dynamic-body:hover {
  border-color: #3a4651;
}

.dynamic-title:focus,
.dynamic-body:focus {
  border-color: #d9ff55;
  outline: 2px solid #d9ff5533;
  background: #0e1318;
}

.canvas-add-menu em {
  font-size: 13px;
  font-style: normal;
}

.dynamic-node {
  display: flex;
  flex-direction: column;
  padding: 0 13px 14px;
  border-color: #45525e;
  background: #151a20;
}

.dynamic-node header {
  margin: 0 -13px 12px;
}

.dynamic-node > strong {
  font-size: 15px;
}

.dynamic-node-image {
  width: calc(100% + 26px);
  max-height: 180px;
  margin: -12px -13px 12px;
  object-fit: contain;
  background: #0b0e11;
}

.dynamic-node > p {
  margin: 8px 0 0;
  overflow: hidden;
  color: #9ca8b3;
  font-size: 13px;
  line-height: 1.55;
}

.canvas-add-menu em {
  display: grid;
  gap: 2px;
  min-width: 0;
  text-align: left;
}

.canvas-add-menu em strong,
.canvas-add-menu em small {
  display: block;
}

.canvas-add-menu em strong {
  color: #eef2f4;
  font-size: 13px;
}

.canvas-add-menu em small {
  overflow: hidden;
  color: #8e9aa5;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dynamic-image {
  padding-bottom: 10px;
}

.dynamic-image-loader {
  min-height: 126px;
  margin: 0 0 9px;
  padding: 0;
  overflow: hidden;
  border: 1px dashed #52606c;
  border-radius: 9px;
  background: #0d1115;
  color: #aeb8c1;
  cursor: pointer;
}

.dynamic-image-loader:active,
.dynamic-node-actions button:active,
.canvas-add-menu button:active {
  transform: scale(.98);
}

.dynamic-image-loader > span {
  min-height: 126px;
  display: grid;
  place-content: center;
  gap: 4px;
  text-align: center;
}

.dynamic-image-loader > span b {
  color: var(--lime);
  font-size: 26px;
  font-weight: 400;
}

.dynamic-image-loader > span strong {
  color: #edf2f4;
  font-size: 14px;
}

.dynamic-image-loader > span small {
  color: #73808b;
  font-size: 10px;
}

.dynamic-image-loader.loaded {
  border-style: solid;
  border-color: #323e48;
}

.dynamic-image-loader .dynamic-node-image {
  width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  object-fit: contain;
}

.dynamic-node-actions button:disabled {
  cursor: not-allowed;
  opacity: .42;
}

.semantic-state {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 2px;
  color: #8f9aa5;
  font-size: 10px;
}

.semantic-state span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.semantic-state i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #65727d;
}

.semantic-state.state-working i {
  background: #ffc66b;
  box-shadow: 0 0 0 4px #ffc66b18;
  animation: semantic-pulse 900ms ease-in-out infinite alternate;
}

.semantic-state.state-done {
  color: #8fd8ba;
}

.semantic-state.state-done i {
  background: #65c99f;
}

.semantic-state.state-error {
  color: #ef9a9a;
}

.semantic-state.state-error i {
  background: #e86b6b;
}

.semantic-state.state-cancelled {
  color: #c9a970;
}

.semantic-state.state-cancelled i,
.semantic-state.state-detached i {
  background: #c9a970;
}

.semantic-state.state-detached {
  color: #c9a970;
}

.semantic-actions {
  flex-wrap: wrap;
}

.semantic-actions button:first-child {
  flex: 1 1 132px;
}

.semantic-actions button.cancel {
  border-color: #8e6c38;
  background: #302719;
  color: #ffd38b;
}

.semantic-actions button.disconnect {
  flex: 0 0 auto;
  border-color: #6b4646;
  background: #2b1d1f;
  color: #ffaaaa;
}

.association-prompts {
  display: grid;
  gap: 5px;
  max-height: 82px;
  margin: 0 10px 8px;
  overflow: auto;
}

.association-prompts button {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 8px;
  border: 1px solid #413d59;
  border-radius: 6px;
  background: #211f31;
  color: #d8d0ff;
  font-size: 11px;
}

.association-prompts button b {
  color: #d9ff55;
  font-size: 10px;
  font-weight: 600;
}

.director-flow .react-flow__edge.selected .react-flow__edge-path {
  stroke: #d9ff55 !important;
  stroke-width: 3 !important;
  filter: drop-shadow(0 0 5px #d9ff5588);
}

.canvas-edge-toolbar {
  position: absolute;
  left: 50%;
  top: 56px;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 7px 6px 10px;
  border: 1px solid #4a5661;
  border-radius: 9px;
  background: rgba(19, 24, 29, .96);
  color: #cbd3da;
  box-shadow: 0 12px 32px #0009;
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.canvas-edge-toolbar span {
  font-size: 11px;
}

.canvas-edge-toolbar button {
  min-height: 28px;
  padding: 0 9px;
  border: 1px solid #754848;
  border-radius: 6px;
  background: #321f21;
  color: #ffaaaa;
  font-size: 11px;
}

.dynamic-text .dynamic-body,
.dynamic-idea .dynamic-body,
.dynamic-note .dynamic-body {
  flex: 1 1 auto;
  min-height: 70px;
}

.semantic-actions {
  padding: 0;
}

.semantic-actions button {
  width: 100%;
  justify-content: center;
}

.dynamic-note {
  padding: 0 12px 12px;
  border-color: #75652d;
  background: linear-gradient(145deg, #413919, #29250f);
  box-shadow: 0 18px 48px #0009, 0 1px 0 #fff2 inset;
}

.dynamic-note header {
  margin: 0 -12px 8px;
  border-bottom-color: #716330;
  background: #4d431c;
}

.dynamic-note .node-type {
  color: #ffe58d;
}

.dynamic-note .note-body {
  width: 100%;
  margin: 0;
  padding: 8px;
  color: #fff1b9;
  font-size: 14px;
  line-height: 1.55;
}

.dynamic-note .note-body:focus {
  border-color: #ffe58d;
  outline-color: #ffe58d33;
  background: #28230d;
}

.react-flow__edge-text {
  fill: #dce4e9;
  font-size: 10px;
}

.react-flow__edge-textbg {
  fill: #11171d;
  fill-opacity: .96;
}

@keyframes semantic-pulse {
  to { transform: scale(1.25); opacity: .65; }
}

.director-flow .react-flow__controls {
  left: 14px;
  bottom: 14px;
  overflow: hidden;
  border: 1px solid #35414b;
  border-radius: 9px;
  box-shadow: 0 12px 32px #0009;
}

.director-flow .react-flow__controls-button {
  width: 32px;
  height: 32px;
  border-color: #313a43;
  background: #171c21;
  color: #dce4e9;
}

.director-flow .react-flow__controls-button:hover {
  background: #252d34;
}

.director-flow .react-flow__controls-button svg {
  fill: currentColor;
}

.director-flow .react-flow__minimap {
  right: 14px;
  bottom: 14px;
  width: 148px;
  height: 92px;
  overflow: hidden;
  border: 1px solid #35414b;
  border-radius: 9px;
  background: #0e1216;
  box-shadow: 0 12px 32px #0009;
}

.canvas-operation-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 6;
  padding: 7px 10px;
  border: 1px solid #303a43;
  border-radius: 8px;
  background: rgba(15, 19, 23, .88);
  color: #9da8b2;
  font-size: 12px;
  pointer-events: none;
  transform: translateX(-50%);
  backdrop-filter: blur(12px);
}

.canvas-connection-hint {
  position: absolute;
  left: 50%;
  top: 16px;
  z-index: 1200;
  padding: 8px 12px;
  border: 1px solid #9cbf3e;
  border-radius: 8px;
  background: rgba(25, 31, 19, .94);
  color: #e4ff8a;
  font-size: 12px;
  pointer-events: none;
  transform: translateX(-50%);
  box-shadow: 0 10px 30px #0008;
  backdrop-filter: blur(12px);
}

.canvas-connection-feedback {
  position: absolute;
  left: 50%;
  bottom: 58px;
  z-index: 32;
  transform: translateX(-50%);
  padding: 8px 12px;
  border: 1px solid #78d6a455;
  border-radius: 999px;
  background: #10261fd9;
  box-shadow: 0 10px 26px #0007;
  color: #a8edc8;
  font-size: 12px;
  pointer-events: none;
}

.react-flow__edge-interaction {
  stroke-width: 28px;
}

.canvas-result-label {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 5;
  width: auto;
  height: auto;
  pointer-events: none;
}

.canvas-result-label .group-label {
  position: static;
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 6px 9px;
  border: 1px solid #303a43;
  border-radius: 7px;
  background: rgba(14, 18, 22, .86);
  backdrop-filter: blur(10px);
}

.canvas-result-label .result-access-note {
  display: none;
}

.canvas-result-label.hidden {
  display: none;
}

.canvas-shell > .zoom-controls,
.canvas-shell > .minimap {
  display: none;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .node-context-menu,
  .canvas-add-menu {
    animation: none;
  }

  .director-flow .node,
  .director-handle,
  .source-image-button span {
    transition: none;
  }
}

@media (max-width: 1120px) {
  .canvas-operation-hint {
    display: none;
  }
}
