.svelte-flow__nodes {
  .svelte-flow__node {
    box-sizing: border-box;
    cursor: default !important;
    border: 3px solid transparent;
    border-radius: 5px;

    .svelte-flow__handle {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 16px;
      height: 16px;
      background: transparent;
      border: none;

      &::after {
        width: 8px;
        height: 8px;
        content: ' ';
        background: var(--tf-primary-color);
        border-radius: 100%;
        transition:
          width 0.1s,
          height 0.1s;
      }

      &:hover {
        &::after {
          width: 16px;
          height: 16px;
        }
      }
    }

    div.loop-handle-wrapper {
      &::after {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100px;
        height: 20px;
        color: var(--tf-loop-handle-text);
        content: '循环体';
        background: var(--tf-primary-color);
        border-radius: 0;
      }

      &:hover {
        &::after {
          width: 100px;
          height: 20px;
        }
      }
    }

    &::after {
      position: absolute;
      top: -2px;
      left: -2px;
      width: calc(100% + 2px);
      height: calc(100% + 2px);
      content: ' ';
      border: 1px solid var(--tf-node-outline-color);
      border-radius: 5px;
    }

    &:hover {
      border: 3px solid var(--tf-node-hover-border);
    }

    &.selectable.selected {
      border: 3px solid var(--tf-node-hover-border);
      box-shadow: var(--xy-node-boxshadow-selected);
    }

    &:hover::after {
      display: none;
    }

    &.selectable.selected::after {
      display: none;
    }
  }
}

.tf-flow-line-path {
  stroke: var(--xy-edge-stroke);
  stroke-width: var(
    --xy-edge-stroke-width,
    var(--xy-edge-stroke-width-default)
  );
}

.tf-flow-line-path--animated {
  stroke-dasharray: 8 6;
  animation: tf-edge-flow 1.2s linear infinite;
}

@keyframes tf-edge-flow {
  from {
    stroke-dashoffset: 0;
  }

  to {
    stroke-dashoffset: -14;
  }
}

.tf-node-wrapper {
  min-width: 300px;
  background: var(--tf-bg-surface);
  border-radius: 5px;

  &-body {
    padding: 10px;
  }

  &--llm {
    min-width: 296px;
    max-width: 296px;
  }
}

.svelte-flow__attribution a {
  display: none;
}

.tf-bottom-dock {
  position: absolute;
  bottom: var(--tf-toolbar-bottom, 20px);
  left: 50%;
  z-index: 200;
  display: flex;
  gap: 8px;
  align-items: center;
  transform: translateX(-50%);
}

/* 单行统一工具栏 */
.tf-unified-bar {
  display: inline-flex;
  gap: 2px;
  align-items: center;
  height: 40px;
  padding: 0 4px;
  background: var(--tf-bg-surface);
  border: 1px solid var(--tf-border-color);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgb(0 0 0 / 8%);

  > * {
    flex-shrink: 0;
  }
}

/* 分割线 */
.tf-bar-divider {
  flex-shrink: 0;
  width: 1px;
  height: 20px;
  margin: 0 4px;
  background: var(--tf-border-color);
}

/* 图标按钮 */
.tf-bar-btn {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--tf-text-secondary);
  cursor: pointer;
  border-radius: 7px;
  transition:
    background 0.15s,
    color 0.15s;

  svg {
    width: 17px;
    height: 17px;
    pointer-events: none;
    fill: currentcolor;
  }

  &:hover {
    color: var(--tf-text-primary);
    background: var(--tf-bg-hover);
  }

  &.tf-bar-btn-active {
    color: var(--tf-primary-color);
    background: var(--tf-bg-hover);
  }
}

.tf-bar-run-btn {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  flex-shrink: 0;
  gap: 6px;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  color: #fff;
  cursor: pointer;
  background: #13b33f;
  border-radius: 8px;
  transition: filter 0.15s;

  svg {
    width: 14px;
    height: 14px;
    pointer-events: none;
    fill: currentcolor;
  }

  &:hover {
    filter: brightness(0.95);
  }
}

.tf-bar-add-btn {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  color: var(--tf-primary-color);
  cursor: pointer;
  background: #e9edff;
  border-radius: 8px;
  transition:
    filter 0.15s,
    background 0.15s;

  &:hover {
    background: #dde5ff;
    filter: brightness(0.98);
  }
}

/* 百分比缩放选择器单元 */
.tf-zoom-select-wrap {
  position: relative;
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 32px;
  padding: 0 6px 0 8px;
  cursor: pointer;
  border-radius: 7px;
  transition: background 0.15s;

  &:hover {
    background: var(--tf-bg-hover);
  }

  .tf-zoom-icon {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    pointer-events: none;
    fill: var(--tf-text-secondary);
  }

  .tf-zoom-select {
    min-width: 48px;
    padding: 0;
    font-size: 13px;
    font-weight: 500;
    line-height: 1;
    color: var(--tf-text-primary);
    text-align: center;
    appearance: none;
    cursor: pointer;
    outline: none;
    background: transparent;
    border: none;
  }

  .tf-zoom-chevron {
    flex-shrink: 0;
    width: 14px;
    height: 14px;
    pointer-events: none;
    fill: var(--tf-text-secondary);
  }
}

.tf-zoom-select-simple {
  min-width: 64px;
  height: 32px;
  padding: 0 8px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  color: var(--tf-text-primary);
  text-align: center;
  appearance: none;
  cursor: pointer;
  outline: none;
  background: transparent;
  border: none;
  border-radius: 7px;

  &:hover {
    background: var(--tf-bg-hover);
  }
}

.tf-toolbar {
  position: relative;
  display: inline-flex;
  align-items: center;

  &-panel {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 260;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: min(520px, calc(100vw - 40px));
    max-height: min(390px, calc(100vh - 220px));
    padding: 8px;
    overflow: hidden;
    background: var(--tf-bg-surface);
    border: 1px solid var(--tf-border-color);
    border-radius: 12px;
    box-shadow: var(--tf-shadow-soft);
    transform: translateX(-50%);
  }

  &-trigger {
    border: none;
  }

  &-trigger-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    svg {
      width: 16px;
      height: 16px;
      fill: currentcolor;
    }
  }
}
